Main Content

mxCreateStructMatrix (C)

2-D structure array

C Syntax

#include "matrix.h"
mxArray *mxCreateStructMatrix(mwSize m, mwSize n, int nfields, const char **fieldnames);

Description

Call mxCreateStructMatrix to create an unpopulated, two-dimensional, structure mxArray. For information about the structure, see mxCreateStructArray.

Call mxDestroyArray when you finish using the mxArray to deallocate the mxArray and its associated elements.

Input Arguments

expand all

Number of rows, specified as mwSize.

Number of columns, specified as mwSize.

Number of fields in each element, specified as int.

One or more field names, specified as const char **.

Field names must be valid MATLAB® identifiers, which means they cannot be NULL or empty. Field names are case-sensitive. To determine the maximum length of a field name, use the namelengthmax function.

Output Arguments

expand all

Pointer to an mxArray, specified as mxArray *, if successful.

The function is unsuccessful when there is not enough free heap space to create the mxArray.

  • MEX file — Function terminates the MEX file and returns control to the MATLAB prompt.

  • Standalone (non-MEX file) application — Function returns 0.

Examples

See these examples in matlabroot/extern/examples/refbook:

Introduced before R2006a