MATLAB POLYSPACE RELEASE NOTES Manuel d'utilisateur Page 155

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 240
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 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
Vue de la page 154
1 2 ... 150 151 152 153 154 155 156 157 158 159 160 ... 239 240

Commentaires sur ces manuels

Pas de commentaire