| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
#include "matrix.h" mxArray *mxCreateCellArray(mwSize ndim, const mwSize *dims);
mwPointer mxCreateCellArray(ndim, dims) mwSize ndim, dims
Number of dimensions in the created cell. For example, to create a three-dimensional cell mxArray, set ndim to 3.
Dimensions array. Each element in the dimensions array contains the size of the mxArray in that dimension. For example, in C, setting dims[0] to 5 and dims[1] to 7 establishes a 5-by-7 mxArray. In Fortran, setting dims(1) to 5 and dims(2) to 7 establishes a 5-by-7 mxArray. In most cases, there should be ndim elements in the dims array.
Pointer to the created cell mxArray, if successful. If unsuccessful in a stand alone (non-MEX-file) application, mxCreateCellArray returns NULL in C (0 in Fortran). If unsuccessful in a MEX-file, the MEX-file terminates and control returns to the MATLAB prompt. The most common cause of failure is insufficient free heap space.
Use mxCreateCellArray to create a cell mxArray whose size is defined by ndim and dims. For example, in C, to establish a three-dimensional cell mxArray having dimensions 4-by-8-by-7, set:
ndim = 3; dims[0] = 4; dims[1] = 8; dims[2] = 7;
In Fortran, to establish a three-dimensional cell mxArray having dimensions 4-by-8-by-7, set:
ndim = 3; dims(1) = 4; dims(2) = 8; dims(3) = 7;
The created cell mxArray is unpopulated; mxCreateCellArray initializes each cell to NULL. To put data into a cell, call mxSetCell.
Any trailing singleton dimensions specified in the dims argument are automatically removed from the resulting array. For example, if ndim equals 5 and dims equals [4 1 7 1 1], the resulting array is given the dimensions 4-by-1-by-7.
See phonebook.c in the matlabroot/extern/examples/refbook folder
mxCreateCellMatrix, mxGetCell, mxSetCell, mxIsCell
![]() | mxCopyReal8ToPtr (Fortran) | mxCreateCellMatrix (C and Fortran) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |