MATLAB Application Program Interface
  Go to function:
    Search    Help Desk 
mxGetNumberOfFields    Examples   See Also

Get the number of fields in a structure mxArray

C Syntax

Arguments

array_ptr
  Pointer to a structure mxArray.

Returns

The number of fields, on success. Returns 0 on failure. The most common cause of failure is that array_ptr is not a structure mxArray. Call mxIsStruct to determine if array_ptr is a structure.

Description

Call mxGetNumberOfFields to determine how many fields are in the specified structure mxArray.

Once you know the number of fields in a structure, it is easy to loop through every field in order to set or to get field values.

Examples

See the example in the mxGetFieldNameByNumber reference page, or mxgetnumberoffields.c in the mx subdirectory of the examples directory.

See Also

mxGetField, mxIsStruct, mxSetField



[ Previous | Help Desk | Next ]