mxCreateString (C and Fortran)

1-N array initialized to specified string

C Syntax

#include "matrix.h"
mxArray *mxCreateString(const char *str);

Fortran Syntax

mwPointer mxCreateString(str)
character*(*) str



String that is to serve as the mxArray's initial data


Pointer to the created mxArray, if successful. If unsuccessful in a standalone (non-MEX-file) application, returns NULL in C (0 in Fortran). If unsuccessful in a MEX-file, the MEX-file terminates and returns control to the MATLAB® prompt. The function is unsuccessful when there is not enough free heap space to create the mxArray.


Use mxCreateString to create a string mxArray initialized to str. Many MATLAB functions (for example, strcmp and upper) require string array inputs.

Free the string mxArray when you are finished using it. To free a string mxArray, call mxDestroyArray.


See the following examples in matlabroot/extern/examples/refbook.

See the following examples in matlabroot/extern/examples/mx.

See the following examples in matlabroot/extern/examples/eng_mat.

Was this topic helpful?