External Interfaces Reference Previous page   Next Page
mxSetField

Set structure array field, given field name and index

C Syntax

Arguments

array_ptr
   Pointer to a structure mxArray. Call mxIsStruct to determine if array_ptr points 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. See mxCalcSingleSubscript for details on calculating an index.

field_name
   The name of the field whose value you are assigning. Call mxGetFieldNameByNumber or mxGetFieldNumber to determine existing field names.

value
   Pointer to the mxArray you are assigning.

Description

Use mxSetField to assign a value to the specified element of the specified field. In pseudo-C terminology, mxSetField performs the assignment

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 should free this old mxArray immediately before or after calling mxSetField.

Calling

is equivalent to calling

Examples

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

See Also

mxCreateStructArray, mxCreateStructMatrix, mxGetField, mxGetFieldByNumber, mxGetFieldNameByNumber, mxGetFieldNumber, mxGetNumberOfFields, mxIsStruct, mxSetFieldByNumber


Previous page  mxSetDimensions mxSetFieldByNumber Next page

© 1994-2005 The MathWorks, Inc.