| MATLAB Application Program Interface | Search  Help Desk |
| mxGetN | Examples See Also |
Get the total number of columns in a two-dimensional mxArray or the total number of elements in dimensions 2 through N for an m-by-n array.
C Syntax
#include "matrix.h" int mxGetN(const mxArray *array_ptr);
Arguments
array_ptrmxArray.
Returns
The number of columns in themxArray.
Description
CallmxGetN to determine the number of columns in the specified mxArray.
If array_ptr is an N-dimensional mxArray, mxGetN is the product of dimensions 2 through N. For example, if array_ptr points to a four-dimensional mxArray having dimensions 13-by-5-by-4-by-6, then mxGetN returns the value 120 (5x4x6). If the specified mxArray has more than two dimensions and you need to know exactly how many elements are in each dimension, then call mxGetDimensions.
If array_ptr points to a sparse mxArray, mxGetN still returns the number of columns, not the number of occupied columns.
Examples
Seeconvec.c in the refbook subdirectory of the examples directory.
For additional examples, see fulltosparse.c, revord.c, timestwo.c, and xtimesy.c in the refbook subdirectory of the examples directory; see explore.c, mexget.c, mexlock.c, mexsettrapflag.c and yprime.c in the mex subdirectory of the examples directory; see mxmalloc.c, mxsetdimensions.c, mxgetnzmax.c, and mxsetnzmax.c in the mx subdirectory of the examples directory.
See Also
mxGetM, mxGetNumberOfDimensions, mxSetM, mxSetN