Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Expand
titleopprett_pokemon.m
Code Block
titleopprett_pokemon.m
pkms_celle = { 'Charmander', 8, 'N',  7; 
               'Pikachu',   10, 'J',  8; 
               'Dewgong',    1, 'A',  1; 
               'Exeggutor',  1, 'S', 10 } 

 

Videoforklaring (

...

21:

...

34

Del 1 (7:30)Del 2 (mm4:ss55)Del 3 (mm9:ss09)
Widget Connector
urlhttps://www.youtube.com/watch?v=uzUJ5JcZ6ns
 
Widget Connector
urlhttps://www.youtube.com/watch?v=iEwaR9TmqMY
Widget Connector
urlhttps://www.youtube.com/watch?v=7Yy5MkWZhqo
 
Oppgaveintroduksjon, og løsning av oppgave a). 

Generelt om valgene man har for å bruke structs til å
representere samlinger med verdier.

Løsning av oppgave b). 

Løsningsforslag

Expand
titleHvis du har prøvd selv, trykk her for å se svaret...
Expand
titleOppgave a)
Code Block
titleforekomst_struct.m
function retur = forekomst_struct(forekomst_celleliste)
    retur.navn = forekomst_celleliste{1};
    retur.antall = forekomst_celleliste{2};
    retur.pos = struct('rad', forekomst_celleliste{3}, ...
                       'kol', forekomst_celleliste{4});
 
	%% Kan også lage siste felt gradvis:
    % retur.pos.rad = forekomst_celleliste{3};
    % retur.pos.kol = forekomst_celleliste{4};
end 
Expand
titleOppgave b)
Code Block
titleforekomster_struct.m
function retur = forekomster_struct(forekomst_cellematrise)
    retur.navn = forekomst_cellematrise(:, 1)';
    retur.antall = [forekomst_cellematrise{:, 2}];
    retur.pos.kol = forekomst_cellematrise(:, 3)';
    retur.pos.rad = [forekomst_cellematrise{:, 4}];
end