MATLAB Application Program Interface Reference Help Desk

mxCreateCellArray

Purpose

Create an unpopulated N-dimensional cell mxArray

C Syntax

Arguments

ndim

The desired number of dimensions in the created cell. For example, to create a three-dimensional cell mxArray, set ndim to 3.

dims

The dimensions array. Each element in the dimensions array contains the size of the mxArray in that dimension. For example, setting dims[0] to 5 and dims[1] to 7 establishes a 5-by-7 mxArray. In most cases, there should be ndim elements in the dims array.

Returns

A pointer to the created cell mxArray, if successful. If unsuccessful in a stand-alone (nonMEX-file) application, mxCreateCellArray returns NULL. If unsuccessful in a MEX-file, the MEX-file terminates and control returns to the MATLAB prompt. Causes of failure include

Description

Use mxCellArray to create a cell mxArray whose size is defined by ndim and dims. For example, to establish a three-dimensional cell mxArray having dimensions 4-by-8-by-7, set

The created cell mxArray is unpopulated; that is, mxCreateCellArray initializes each cell to NULL. To put data into a cell, call mxSetCell.

Examples

Create a two-dimensional 2-by-2 cell mxArray named amoeba, then populate two of its 4 cells:

The code leaves cell array elements (1,2) and (2,1) unpopulated.

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

See Also

mxCreateCellMatrix, mxGetCell, mxSetCell, mxIsCell



[ Previous | Help Desk | Next ]