External Interfaces/API Reference |
Get a field name, given a field number in a structure array
Fortran Syntax
Arguments
pm
Pointer to a structure mxArray
.
fieldnumber
The position of the desired field. For instance, to get the name of the first field, set fieldnumber
to 1
; to get the name of the second field, set fieldnumber
to 2
; and so on.
Returns
The n
th field name, on success. Returns 0
on failure. Common causes of failure include:
pm
that does not point to a structure mxArray
. Call mxIsStruct
to determine if pm
points to a structure mxArray
.
fieldnumber
greater than the number of fields in the structure mxArray
. (Remember that fieldnumber
1
represents the first field, so index
N
represents the last field.)
Description
Call mxGetFieldNameByNumber
to get the name of a field in the given structure mxArray
. A typical use of mxGetFieldNameByNumber
is to call it inside a loop to get the names of all the fields in a given mxArray
.
Consider a MATLAB structure initialized to
patient.name = 'John Doe'; patient.billing = 127.00; patient.test = [79 75 73; 180 178 177.5; 220 210 205];
The fieldnumber
1
represents the field name name
; fieldnumber
2
represents field name billing
; fieldnumber
3
represents field name test
. A fieldnumber
other than 1
, 2
, or 3
causes mxGetFieldNameByNumber
to return 0
.
See Also
mxGetField
, mxIsStruct
, mxSetField
mxGetFieldByNumber | mxGetFieldNumber |