Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Hva skrives ut til skjerm hvis vi kjører scriptet «oppgave_6.m»?

Code Block
titleoppgave_6.m
s1 = struct('x', {1, 2, 3}, 'y', {3, 2, 1}, 'verdi', {123, true, 'test'});
s2 = struct('x', cell(1, 3), 'y', 0, 'verdi', []);
s3 = repmat(struct('x', 1, 'y', 2, 'verdi', 'test'), 1, 3);
s4 = struct('x', 1:3, 'y', [3,2,1], 'verdi', {{123, true, 'test'}});
fprintf('x: %d, y: %d, z: %s\n', s1(3).x, s1(3).y, s1(3).verdi);
fprintf('x: %d, y: %d, z: %s\n', s2(3).x, s2(3).y, s2(3).verdi);
fprintf('x: %d, y: %d, z: %s\n', s3(3).x, s3(3).y, s3(3).verdi);
fprintf('x: %d, y: %d, z: %s\n', s4.x(3), s4.y(3), s4.verdi{3});

...