MATLAB Function Reference    

Create structure array



s = struct('field1',{},'field2',{},...) creates an empty structure with fields field1, field2, ...

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

produces a structure array s:

The value arrays have been distributed among the fields of s:

Similarly, the command

produces an empty structure a.b with field z.

See Also

isstruct, fieldnames, isfield, orderfields, rmfield, deal, cell2struct, struct2cell

  strtok struct2cell