External Interfaces/API Reference |
Set a field value in a structure array, given a field number and an index
Fortran Syntax
subroutine mxSetFieldByNumber(pm, index, fieldnumber, value) integer*4 pm, index, fieldnumber, value
Arguments
pm
Pointer to a structure mxArray
. Call mxIsStruct
to determine if pm
points to a structure mxArray
.
index
The desired element. The first element of an mxArray
has an index of 1
, the second element has an index of 2
, and the last element has an index of N
, where N
is the total number of elements in the structure mxArray
.
fieldnumber
The position of the field whose value you want to extract. The first field within each element has a fieldnumber
of 1
, the second field has a fieldnumber
of 2
, and so on. The last field has a fieldnumber
of N
, where N
is the number of fields.
value
The value you are assigning. Use one of the mxCreate*
functions to create the value
mxArray
.
Description
Use mxSetFieldByNumber
to assign a value
to the specified element of the specified field. If there is already a value at the given position, the value
pointer you specified overwrites the old value pointer. However, mxSetFieldByNumber
does not free the dynamic memory that the old value pointer pointed to. Consequently, you are responsible for destroying this mxArray
.
mxSetFieldByNumber
is almost identical to mxSetField
; however, the former takes a field number as its third argument, and the latter takes a field name as its third argument.
See Also
mxCreateStructArray
, mxCreateStructMatrix
, mxGetField
, mxGetFieldByNumber
, mxGetFieldNameByNumber
, mxGetNumberOfFields
, mxIsStruct
, mxSetField
mxSetField | mxSetImagData |