Create structure array
s = struct
creates a scalar (1-by-1) structure
with no fields.
s = struct(
creates
a structure array with the specified field and values. The field
,value
)value
input
argument can be any data type, such as a numeric, logical, character,
or cell array.
If value
is not a
cell array, then s
is a scalar structure, where s.(field)
= value
.
If value
is a cell array, then s
is
a structure array with the same dimensions as value
.
Each element of s
contains the corresponding element
of value
. For example, s = struct('f',{'a','b'})
returns s(1).f
= 'a'
and s(2).f = 'b'
.
If value
is an empty cell array {}
,
then s
is an empty (0-by-0) structure.
s = struct(field1,value1,...,fieldN,valueN)
creates
a structure array with multiple fields. Any nonscalar cell arrays
in the set value1,...,valueN
must have the same
dimensions.
If none of the value
inputs is
a cell array, or if all value
inputs that are cell
arrays are scalars, then s
is a scalar structure.
If any of the value
inputs is a
nonscalar cell array, then s
has the same dimensions
as the nonscalar cell array. For any value
that
is a scalar cell array or an array of any other data type, struct
inserts
the contents of value
in the relevant field for
all elements of s
.
If any value
input is an empty
cell array, {}
, then output s
is
an empty (0-by-0) structure. To specify an empty field and keep the
values of the other fields, use []
as a value
input
instead.
s = struct([])
creates an empty (0-by-0)
structure with no fields.
s = struct(
creates
a scalar structure with field names and values that correspond to
properties of obj
)obj
. The struct
function
does not convert obj
, but rather creates s
as
a new structure. This structure does not retain the class information,
so private, protected, and hidden properties become public fields
in s
. The struct
function issues
a warning when you use this syntax.
cell2struct
| fieldnames
| isfield
| isstruct
| orderfields
| rmfield
| struct2cell
| struct2table
| substruct
| table
| table2struct