getfield
Extract a field value from a structure s.
Syntax
R = getfield(s,field)
R = getfield(s,field,idx)
Inputs
- s
- Struct.
- field
- Name of field.
- idx
- Index (or indices) into struct array. Must be stored in a cell array.
Outputs
- R
- Content of the specified field.
Example
a = struct('name', 'Bob', 'age', 33);
R = getfield(a, 'age')
R = 33
a = struct('name', {'Bob', 'Dave'}, 'age', {33, 44});
R = getfield(a, {2}, 'age')
R = 44