MATLAB FINANCIAL DERIVATIVES TOOLBOX Manuel d'utilisateur Page 92

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 119
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 91
91
individual field contents when you type the array name. Instead, it shows a
summary of the kind of information the structure contains.
You can also use the
f
f
i
i
e
e
l
l
d
d
n
n
a
a
m
m
e
e
s
s
function to obtain this information.
f
f
i
i
e
e
l
l
d
d
n
n
a
a
m
m
e
e
s
s returns a cell array of strings containing field names (see the
online help).
As you expand the structure, Matlab fills in unspecified fields with empty
matrices so that:
All structures in the array have the same number of fields
All fields have the same field names
For example, entering “patient(3).name = 'Alan Johnson' ” expands the
patient array to size [1 3]. Now both “patient(3).billing” and “patient(3).test”
contain empty matrices. To see this, type: “patient(3)” to get:
“ans =
name: 'Alan Johnson'
billing: []
test: [] ”
Building structure arrays using the
s
s
t
t
r
r
u
u
c
c
t
t function
You can pre-allocate an array of structures with the
s
s
t
t
r
r
u
u
c
c
t
t function. Its basic
form is [2]:
“str_array =
s
s
t
t
r
r
u
u
c
c
t
t ('field1',val1,'field2',val2, ...)”
where the arguments are field names and their corresponding values. A field
value can be a single value, represented by any Matlab data construct, or a
cell array of values. All field values in the argument list must be of the same
scale (single value or cell array). To create the structure with the patient info
shown before you should have the following syntax (the first command line
instructs for the creation of a 1-by-3 structure will all fields set to empty):
“patient(3)=
s
s
t
t
r
r
u
u
c
c
t
t ('name',[],'billing',[],'test',[]);
Vue de la page 91
1 2 ... 87 88 89 90 91 92 93 94 95 96 97 ... 118 119

Commentaires sur ces manuels

Pas de commentaire