getfield
Get the value of a structure field by name.
Syntax
Section titled “Syntax”f = getfield(s, field)f = getfield(s, ij, field, k)Description
Section titled “Description”Returns the value of the named field. Equivalent to s.(field). With index arguments ij, k, retrieves nested fields from struct arrays or nested struct hierarchies.
Examples
Section titled “Examples”s.x = 42;getfield(s, 'x') % 42s.(getfield(s, 'x')) % equivalent to dynamic field accessSee also
Section titled “See also”setfield— Set the value of a structure field by name.fieldnames— List of field names in a structure.isfield— Test whether a structure contains a named field.