Programming |
Multidimensional Structure Arrays
Multidimensional structure arrays are extensions of rectangular structure arrays. Like other types of multidimensional arrays, you can build them using direct assignment or the cat
function:
patient(1,1,1).name = 'John Doe';patient(1,1,1).billing = 127.00; patient(1,1,1).test = [79 75 73; 180 178 177.5; 220 210 205]; patient(1,2,1).name = 'Ann Lane';patient(1,2,1).billing = 28.50; patient(1,2,1).test = [68 70 68; 118 118 119; 172 170 169]; patient(1,1,2).name = 'Al Smith';patient(1,1,2).billing = 504.70; patient(1,1,2).test = [80 80 80; 153 153 154; 181 190 182]; patient(1,2,2).name = 'Dora Jones';patient(1,2,2).billing = 1173.90; patient(1,2,2).test = [73 73 75; 103 103 102; 201 198 200];
Applying Functions to Multidimensional Structure Arrays
To apply functions to multidimensional structure arrays, operate on fields and field elements using indexing. For example, find the sum of the columns of the test
array in patient(1,1,2)
:
Similarly, add all the billing
fields in the patient
array:
Multidimensional Cell Arrays | Summary of Matrix and Array Functions |
© 1994-2005 The MathWorks, Inc.