MATLAB Application Program Interface Reference Help Desk

mxGetNumberOfFields

Purpose

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, mxGetFieldIndex, mxGetFieldNameByIndex, mxIsStruct, mxSetField



[ Previous | Help Desk | Next ]