External Interfaces Reference |
Set structure array field value, given field name and index
Fortran Syntax
subroutine mxSetField(pm, index, fieldname, value) integer*4 pm, index, value character*(*) fieldname
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
.
fieldname
The name of the field whose value you are assigning. Call mxGetFieldNameByNumber
to determine existing field names.
value
Pointer to the mxArray
you are assigning. Use one of the mxCreate*
functions to create the value
mxArray
.
Description
Use mxSetField
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, mxSetField
does not free the dynamic memory that the old value pointer pointed to. Consequently, you are responsible for destroying this mxArray
.
mxSetField
is almost identical to mxSetFieldByNumber
; however, the former takes a field name as its third argument, and the latter takes a field number as its third argument.
See Also
mxCreateStructArray
, mxCreateStructMatrix
, mxGetField
, mxGetFieldByNumber
, mxGetFieldNameByNumber
, mxGetNumberOfFields
, mxIsStruct
, mxSetFieldByNumber
mxSetDimensions | mxSetFieldByNumber |
© 1994-2005 The MathWorks, Inc.