MATLAB Application Program Interface | Search  Help Desk |
mxCreateStructMatrix | Examples See Also |
Create an unpopulated 2-dimensional structure mxArray
#include "matrix.h" mxArray *mxCreateStructMatrix(int m, int n, int nfields, const char **field_names);m
mxArray
, if successful; otherwise, returns NULL
. The most likely cause of failure is insufficient heap space to hold the returned mxArray
.
mxCreateStructMatrix
and mxCreateStructArray
are almost identical. The only difference is that mxCreateStructMatrix
can only create two-dimensional mxArrays
, while mxCreateStructArray
can create mxArrays
having two or more dimensions.
Create a two-dimensional structure mxArray
having the dimensions 5-by-7:
int rows=100, cols=1; int number_of_fields=4; const char *fieldnames[] = {"pressure", "wind speed", "wind direction", "dewpoint"}; mxArray *struct_array_ptr; /* Create a 100-by-1 structure mxArray. */ struct_array_ptr = mxCreateStructMatrix(rows, cols, number_of_fields, fieldnames); /* Populate the structure mxArray with data. */ ...The created structure
mxArray
is unpopulated. See the mxCreateStructArray
reference page for sample code demonstrating how to populate a structure mxArray
. For an additional example of mxCreateStructMatrix
, see mxcreatestructmatrix.c
in the mx
subdirectory of the examples
directory.
mxCreateStructArray
, mxGetFieldByNumber
, mxGetFieldNameByNumber
, mxGetFieldNumber
, mxIsStruct