MATLAB POLYSPACE RELEASE NOTES Manuale Utente Pagina 155

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 240
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 154
Other Data Structures
Now the structure is large enough that only a summary is printed:
S=
1x3 struct array with fields:
name
score
grade
There are several ways to reassemble the various fields into other MATLAB
arrays. They are mostly based on the notation of a comma-separated list.If
you type
S.score
it is the same as typing
S(1).score, S(2).score, S(3).scor e
which is a comma-separated list.
If you enclose the expression that generates such a list within square
brackets, MATLAB s tores each item from the lis t in an array. In this example,
MATLAB creates a numeric row vector containing the
score field of each
element of structure array
S:
scores = [S.score]
scores =
83 91 70
avg_score = sum(scores)/length(sco res)
avg_score =
81.3333
To create a character array from one of the text fields (name, for example), call
the
char functio n on the comma-separated list produced by S.name:
names = char(S.name)
names =
Ed Plum
Toni Miller
Jerry Garcia
4-17
Vedere la pagina 154
1 2 ... 150 151 152 153 154 155 156 157 158 159 160 ... 239 240

Commenti su questo manuale

Nessun commento