External Interfaces Reference |
Get field value, given field name and index into structure array
C Syntax
#include "matrix.h" mxArray *mxGetField(const mxArray *array_ptr, int index, const char *field_name);
Arguments
array_ptr
Pointer to a structure mxArray
.
index
The desired element. The first element of an mxArray
has an index
of 0
, the second element has an index
of 1
, and the last element has an index
of N-1
, where N is the total number of elements in the structure mxArray
.
field_name
The name of the field whose value you want to extract.
Returns
A pointer to the mxArray
in the specified field at the specified field_name
, on success. Returns NULL
if passed an invalid argument or if there is no value assigned to the specified field. Common causes of failure include:
array_ptr
that does not point to a structure mxArray
. To determine if array_ptr
points to a structure mxArray
, call mxIsStruct
.
index
to an element past the end of the mxArray
. For example, given a structure mxArray
that contains 10 elements, you cannot specify an index
greater than 9.
field_name
. Call mxGetFieldNameByNumber
or mxGetFieldNumber
to get existing field name
s.
mxArray
.
Description
Call mxGetField
to get the value held in the specified element of the specified field. In pseudo-C terminology, mxGetField
returns the value at
mxGetFieldByNumber
is similar to mxGetField
. Both functions return the same value. The only difference is in the way you specify the field. mxGetFieldByNumber
takes field_num
as its third argument, and mxGetField
takes field_name
as its third argument.
where index
is zero if you have a one-by-one structure.
See Also
mxGetFieldByNumber
, mxGetFieldNameByNumber
, mxGetFieldNumber
, mxGetNumberOfFields
, mxIsStruct
, mxSetField
, mxSetFieldByNumber
mxGetEps | mxGetFieldByNumber |
© 1994-2005 The MathWorks, Inc.