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.

Create 2-D Cell Array

This example shows how to create a cell array in a MEX file, using the mxcreatecellmatrix.c function, which places input arguments in a cell array.

C Code Analysis

To see the code, open the file in MATLAB® Editor.

Create a cell array for the number of input arguments.

cell_array_ptr = mxCreateCellMatrix((mwSize)nrhs,1);

Copy the input arguments into the cell array.

for( i=0; i<(mwIndex)nrhs; i++){

Build and Test Example

Run the following commands from the MATLAB command line.

Build the example.

mex -v mxcreatecellmatrix.c

Create input arguments.

str1 = 'hello';
str2 = 'world';
num = 2012;

Create a 3-x-1 cell array and call disp to display the contents.

The contents of the created cell is:


Related Topics

Was this topic helpful?