External Interfaces/API Reference    
mxGetFieldNumber

Get a field number, given a field name in a structure array

Fortran Syntax

Arguments

pm
   Pointer to a structure mxArray.

fieldname
   The name of a field in the structure mxArray.

Returns

The field number of the specified fieldname, on success. The first field has a field number of 1, the second field has a field number of 2, and so on. Returns 0 on failure. Common causes of failure include:

Description

If you know the name of a field but do not know its field number, call mxGetFieldNumber. Conversely, if you know the field number but do not know its field name, call mxGetFieldNameByNumber.

For example, consider a MATLAB structure initialized to

The field name name has a field number of 1; the field name billing has a field number of 2; and the field name test has a field number of 3. If you call mxGetFieldNumber and specify a fieldname of anything other than 'name', 'billing', or 'test', then mxGetFieldNumber returns 0.

Calling

is equivalent to calling

where index is 1 if you have a 1-by-1 structure.

See Also

mxGetField, mxGetFieldByNumber, mxGetFieldNameByNumber, mxGetNumberOfFields, mxSetField, mxSetFieldByNumber


  mxGetFieldNameByNumber mxGetImagData