Next: Processing Data in Structures, Previous: Creating Structures, Up: Data Structures
Other functions that can manipulate the fields of a structure are given below.
Return a cell array of strings naming the elements of the structure struct. It is an error to call
fieldnames
with an argument that is not a structure.
Return true if the expression expr is a structure and it includes an element named name. The first argument must be a structure and the second must be a string.
Extract fields from a structure. For example
ss(1,2).fd(3).b=5; getfield (ss, {1,2}, "fd", {3}, "b") ans = 5Note that the function call in the previous example is equivalent to the expression
i1= {1,2}; i2= "fd"; i3= {3}; i4= "b"; ss(i1{:}).(i2)(i3{:}).(i4)See also: setfield, rmfield, isfield, isstruct, fieldnames, struct.