setfield
Set the value of a structure field by name.
Syntax
Section titled “Syntax”s = setfield(s, field, V)s = setfield(s, ij, field, k, V)Description
Section titled “Description”Returns a copy of s with the named field set to V. Equivalent to s.(field) = V. With index arguments, navigates nested structs or struct arrays.
Examples
Section titled “Examples”s = setfield(s, 'x', 99)% equivalent to: s.x = 99;See also
Section titled “See also”getfield— Get the value of a structure field by name.fieldnames— List of field names in a structure.rmfield— Remove fields from a structure.