| MATLAB Application Program Interface Reference | Help Desk |
mxGetNumberOfFields
Get the number of fields in a structuremxArray
#include "matrix.h" int mxGetNumberOfFields(const mxArray *array_ptr);array_ptr
Pointer to a structure mxArray.
array_ptr is not a structure mxArray. Call mxIsStruct to determine if array_ptr is a structure.
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.
See the example in the mxGetFieldNameByNumber reference page, or mxGetNumberOfFields.c in the mx subdirectory of the examples directory.
mxGetField, mxGetFieldIndex, mxGetFieldNameByIndex, mxIsStruct, mxSetField