MATLAB FINANCIAL DERIVATIVES TOOLBOX Uživatelský manuál Strana 91

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 119
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 90
90
Building structure arrays using assignment statements
You can build a simple 1-by-1 structure array by assigning data to individual
fields. Matlab automatically builds the structure as you go along. For
example, create the 1-by-1 patient structure array shown at the beginning of
this section [2]:
patient.name = 'John Doe';
patient.billing = 127.00;
patient.test = [79 75 73; 180 178 177.5; 220 210 205];
and if you type: “patient” in the command window you get:
“patient =
name: 'John Doe'
billing: 127
test: [3x3 double] ”
that is an array containing a structure with three fields. To expand the
structure array, add subscripts after the structure name:
patient(2).name = 'Ann Lane';
patient(2).billing = 28.50;
patient(2).test = [68 70 68; 118 118 119; 172 170 169];”
and if you again type: “patient” you will get:
“patient =
1x2 struct array with fields:
name
billing
test ”
The patient structure array now has size [1 2]. Note that once a structure
array contains more than a single element, Matlab does not display
Zobrazit stránku 90
1 2 ... 86 87 88 89 90 91 92 93 94 95 96 ... 118 119

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

Žádné komentáře