Main Content

mxCreateCharArray (C)

N-D mxChar array

C Syntax

#include "matrix.h"
mxArray *mxCreateCharArray(mwSize ndim, const mwSize *dims);


Use mxCreateCharArray to create an N-dimensional mxChar array with each element set to NULL.

MATLAB® automatically removes any trailing singleton dimensions specified in the dims argument. For example, if ndim equals 5 and dims equals [4 1 7 1 1], then the resulting array has the dimensions 4-by-1-by-7.

Input Arguments

expand all

Number of dimensions, specified as mwSize. If you specify 0, 1, or 2, then mxCreateCharArray creates a two-dimensional mxArray.

Dimensions array, specified as const mwSize *.

Each element in the dimensions array contains the size of the array in that dimension. For example, to create a 5-by-7 array, set dims[0] to 5 and dims[1] to 7.

Usually, the dims array contains ndim elements.

Output Arguments

expand all

Pointer to an mxArray of type mxChar, specified as mxArray *.

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 NULL.

Version History

Introduced before R2006a