MATLAB POLYSPACE RELEASE NOTES Uživatelský manuál Strana 154

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 240
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 153
4 Programming
C=
'A'
'rolling'
'stone'
'gathers'
'momentum.'
You can convert a padded character array to a cell array of strings with
C = cellstr(S)
and reverse the process with
S = char(C)
Structures
Structures are multidimensional MATLAB arrays with elements accessed by
textual field designators. For example,
S.name = 'Ed P lum';
S.score = 83;
S.grade = 'B+'
creates a scalar structure with three fields:
S=
name: 'Ed Plum'
score: 83
grade: 'B+'
Like everything else in MATLAB, structures are arrays, so you can insert
additional elements. In this case, each element of the array is a structure with
several fields. The fields can be added one at a time,
S(2).name = 'Toni Miller';
S(2).score = 91;
S(2).grade = 'A-';
or an entire element can be added with a single statement:
S(3) = struct('name','Jerry Garcia',...
'score',70,'grade','C')
4-16
Zobrazit stránku 153
1 2 ... 149 150 151 152 153 154 155 156 157 158 159 ... 239 240

Komentáře k této Příručce

Žádné komentáře