MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
structure new both have two columns, you can concatenate them vertically with a
semicolon separator.

new(1,1).a = 1;
new(1,1).b = 10;
new(1,2).a = 2;
new(1,2).b = 20;
new(2,1).a = 3;
new(2,1).b = 30;
new(2,2).a = 4;
new(2,2).b = 40;

larger = [combined; new]

larger = 3x2 struct array with fields:
a
b

Access field a of the structure larger(2,1). It contains the same value as new(1,1).a.

larger(2,1).a

ans = 1

See Also


Related Examples



  • “Creating, Concatenating, and Expanding Matrices”

  • “Access Data in a Structure Array” on page 11-7

  • “Access Elements of a Nonscalar Struct Array” on page 11-16


11 Structures

Free download pdf