MATLAB Application Program Interface Reference Help Desk

mxCreateCharMatrixFromStrings

Purpose

Create a populated 2-dimensional string mxArray

C Syntax

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

A pointer to a list of strings. The str array must contain at least m strings.

Returns

A pointer to the created string mxArray, if successful. If unsuccessful in a stand-alone (nonMEX-file) application, mxCreateCharMatrixFromStrings returns NULL. 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 mxCreateCharArray 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. The created mxArray has dimensions m-by-max, where max is the length of the longest string in str.

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

Examples

Create a 3-by-22 string mxArray initialized to all the three substrings of Shake:

For an additional example, see mxCreateCharMatrixFromStrings.c in the mx subdirectory of the examples directory.

See Also

mxCreateCharArray, mxCreateString, mxGetString



[ Previous | Help Desk | Next ]