FUNCTION REFERENCE
structfun
Apply a function to each field of a scalar struct.
Apply a function to each field of a scalar struct.
Syntax
A = structfun(f, S)Syntax
A = structfun(f, S, 'UniformOutput', false)Syntax
A = structfun(f, S, 'ErrorHandler', g)Calls f on each field value in field order. By default every call must
return a scalar of one class and the results form a column with one row per
field. With 'UniformOutput', false the results are returned as a struct with
the same field names. With 'ErrorHandler', g(err, value) supplies the result
for a field whose call fails; err has the fields message, identifier and
index. Several outputs are supported.
Example
s.a = 1; s.b = 2; structfun(@(v) v * 2, s) % [2; 4]Differences from MATLAB: uniform results must be numeric, logical or char
scalars.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.