This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mxCreateString (C and Fortran)

1-N array initialized to specified string

C Syntax

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

Fortran Syntax

#include "fintrf.h"
mwPointer mxCreateString(str)
character*(*) str



String used to initialize mxArray data. Only ASCII characters are supported.


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 an mxArray initialized to str. Many MATLAB functions (for example, strcmp and upper) require string array inputs.

mxCreateString supports both multi-byte and single-byte encoded characters. On Windows® and Linux® platforms, the default encoding is specified by the user locale setting.

Free the mxArray when you are finished using it, by calling 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.

Introduced before R2006a

Was this topic helpful?