MATLAB Function Reference | Search  Help Desk |
struct | Examples See Also |
s = struct('field1',values1,'field2',values2,...)
s = struct('field1',values1,'field2',values2,...)
creates a structure array with the specified fields and values. The value arrays values1
, values2
, etc. must be cell arrays of the same size or scalar cells. Corresponding elements of the value arrays are placed into corresponding structure array elements. The size of the resulting structure is the same size as the value cell arrays or 1-by-1 if none of the values is a cell.
The command
s = struct('type',{'big','little'},'color',{'red'},'x',{3 4})produces a structure array
s
:
s = 1x2 struct array with fields: type color xThe value arrays have been distributed among the fields of
s
:
s(1) ans = type: 'big' color: 'red' x: 3 s(2) ans = type: 'little' color: 'red' x: 4
fieldnames
Field names of a structure
getfield
Get field of structure array
rmfield
Remove structure fields
setfield
Set field of structure array