Main Content

mxCreateCharMatrixFromStrings (C)

2-D mxChar array initialized to specified value

C Syntax

#include "matrix.h"
mxArray *mxCreateCharMatrixFromStrings(mwSize m, const char **str);


Use mxCreateCharMatrixFromStrings to create a two-dimensional mxArray, where each row is initialized to a string from str. The mxArray has dimensions m-by-max, where max is the length of the longest string in str.

The mxArray represents its data elements as mxChar rather than as C char.

Input Arguments

expand all

Number of strings, specified as mwSize.

Array of strings, specified as const char **. The array must contain at least m strings.

Output Arguments

expand all

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

The function is unsuccessful when str contains fewer than m strings or 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.


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

Version History

Introduced before R2006a