MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

s(1)


.n(1) .a 1 1 1
1 1 1
1 1 1

.b 1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

.c 17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9

.n(2) 2 2 2
2 2 2
2 2 2

2 0 0 0
0 2 0 0
0 0 2 0
0 0 0 2

34 48 2 16 30
46 10 14 28 32
8 12 26 40 44
20 24 38 42 6
22 36 50 4 18

s(2)

.n(1) .a 1a

.b

.c

.n(2)

1b

1c

2a

2b

2c

.a

.b

.c

.a

.b

.c

Access part of the array in field b of the second element in n within the first element of s:


part_two_eye = s(1).n(2).b(1:2,1:2)


This returns the 2-by-2 upper left corner of 2*eye(4):


part_two_eye =
2 0
0 2


Access Data in Nested Structures
Free download pdf