setfield
Assign value to structure array field
Syntax
Description
S = setfield(
assigns a value to the specified field of the structure S
,field
,value
)S
. For example,
S = setfield(S,'a',1)
makes the assignment S.a =
1
.
As an alternative to setfield
, use dot notation: S.field =
value
. Dot notation is typically more efficient.
If S
does not have the specified field, then
setfield
creates it and assigns value
to
it.
Examples
Input Arguments
Extended Capabilities
Version History
Introduced before R2006a
See Also
getfield
| fieldnames
| isfield
| orderfields
| rmfield
| struct