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

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

The desired number of rows in the created string mxArray. The value you specify for m should equal 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

A pointer to the created string mxArray, if successful. If unsuccessful in a stand alone (non-MEX-file) application, mxCreateCharMatrixFromStrings returns NULL in C (0 in Fortran). If unsuccessful in a MEX-file, the MEX-file terminates and control returns to the MATLAB® prompt. Insufficient free heap space is the primary reason for mxCreateCharMatrixFromStrings to be unsuccessful. 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).

Note that string mxArrays represent their data elements as mxChar rather than as C char.

C Examples

See mxcreatecharmatrixfromstr.c in the mx subdirectory of the examples directory.

See Also

mxCreateCharArray, mxCreateString, mxGetString

  


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