This is machine translation

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

mxCreateCharMatrixFromStrings (C and Fortran)

2-D mxChar array initialized to specified value

C Syntax

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

Fortran Syntax

mwPointer mxCreateCharMatrixFromStrings(m, str)
mwSize m
character*(*) str(m)



Number of rows in the mxArray. The value you specify for m is the number of strings in str.


In C, an array of strings containing at least m strings. In Fortran, a character*n array of size m, where each element of the array is n bytes.


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. Another possible reason for failure is that str contains fewer than m strings.


Use mxCreateCharMatrixFromStrings to create a two-dimensional mxArray, where each row is initialized to a string from str. In C, the created mxArray has dimensions m-by-max, where max is the length of the longest string in str. In Fortran, the created mxArray has dimensions m-by-n, where n is the number of characters in str(i).

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


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

Introduced before R2006a

Was this topic helpful?