External Interfaces Reference Previous page   Next Page
mxGetFieldNumber

Get field number, given field name in structure array

C Syntax

Arguments

array_ptr
   Pointer to a structure mxArray.

field_name
   The name of a field in the structure mxArray.

Returns

The field number of the specified field_name, on success. The first field has a field number of 0, the second field has a field number of 1, and so on. Returns -1 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 has a field number of 0; the field billing has a field number of 1; and the field test has a field number of 2. If you call mxGetFieldNumber and specify a field name of anything other than name, billing, or test, then mxGetFieldNumber returns -1.

Calling

is equivalent to calling

where index is zero if you have a one-by-one structure.

Examples

See mxcreatestructarray.c in the mx subdirectory of the examples directory.

See Also

mxGetField, mxGetFieldByNumber, mxGetFieldNameByNumber, mxGetNumberOfFields, mxSetField, mxSetFieldByNumber


Previous page  mxGetFieldNameByNumber mxGetImagData Next page

© 1994-2005 The MathWorks, Inc.