Documentation

fieldnames

Field names of structure, or public fields ofJavaorMicrosoftCOMobject

Description

example

fields = fieldnames(S)returns the field names of the structure arraySin a cell array.

fields = fieldnames(obj,'-full')returns a cell array of character vectors containing the name, type, attributes, and inheritance of the properties ofobj. The input argumentobjis a Java®orMicrosoft®COMobject.

Examples

collapse all

Create a structure array.

S(1,1).x = linspace(0,2*pi); S(1,1).y = sin(S(1,1).x); S(1,1).title ='y = sin(x)'; S(2,1).x = linspace(0,2*pi); S(2,1).y = cos(S(2,1).x); S(2,1).title ='y = cos(x)'
S=2×3 structx y title

Return the field names in a cell array using thefieldnamesfunction.

fields = fieldnames(S)
fields =3x1 cell array{'x' } {'y' } {'title'}

To return the values of the fields, use thestruct2cellfunction.struct2cellandfieldnamesreturn the values and the field names in the same order.

values = struct2cell(S)
values=3×2 cell{1x100 double} {1x100 double} {1x100 double} {1x100 double} {'y = sin(x)'} {'y = cos(x)'}

Input Arguments

collapse all

Input structure array.

Input object, specified as a Java object orMicrosoft COMobject.

Extended Capabilities

Introduced before R2006a