Skip to Main Content Skip to Search
Product Documentation

mxCreateCharMatrixFromStrings (C and Fortran) - Create populated 2-D string array

C Syntax

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

Fortran Syntax

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

Arguments

m

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

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.

Returns

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.

Description

Use mxCreateCharMatrixFromStrings to create a two-dimensional string 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).

String mxArrays represent their data elements as mxChar rather than as C char.

Examples

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

See Also

mxCreateCharArray, mxCreateString, mxGetString

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS