| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
#include "matrix.h" size_t mxGetN(const mxArray *pm);
mwPointer mxGetN(pm) mwPointer pm
Number of columns in the mxArray.
Call mxGetN to determine the number of columns in the specified mxArray.
If pm is an N-dimensional mxArray, mxGetN is the product of dimensions 2 through N. For example, if pm points to a four-dimensional mxArray having dimensions 13-by-5-by-4-by-6, mxGetN returns the value 120 (5 × 4 × 6). If the specified mxArray has more than two dimensions and you need to know exactly how many elements are in each dimension, call mxGetDimensions.
If pm points to a sparse mxArray, mxGetN still returns the number of columns, not the number of occupied columns.
Note Fortran does not have an equivalent of size_t. mwPointer is a preprocessor macro that provides the appropriate Fortran type. The value returned by this function, however, is not a pointer. |
See convec.c in the matlabroot/extern/examples/refbook folder .
Additional examples:
fulltosparse.c, revord.c, timestwo.c, and xtimesy.c in the matlabroot/extern/examples/refbook folder
explore.c, mexget.c, mexlock.c, mexsettrapflag.c and yprime.c in the matlabroot/extern/examples/mex folder
mxmalloc.c, mxsetdimensions.c, mxgetnzmax.c, and mxsetnzmax.c in the matlabroot/extern/examples/mx folder
See matdemo2.F in the matlabroot/extern/examples/eng_mat folder for sample programs that illustrate how to use the MAT-file routines in a Fortran program.
mxGetM, mxGetDimensions, mxSetM, mxSetN
![]() | mxGetM (C and Fortran) | mxGetNaN (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 |