Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

mxGetN (C and Fortran) - Get number of columns in mxArray

C Syntax

#include "matrix.h"
size_t mxGetN(const mxArray *pm);

Fortran Syntax

mwPointer mxGetN(pm)
mwPointer pm

Arguments

pm

Pointer to an mxArray

Returns

Number of columns in the mxArray.

Description

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.

C Examples

See convec.c in the matlabroot/extern/examples/refbook folder .

Additional examples:

Fortran Examples

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.

See Also

mxGetM, mxGetDimensions, mxSetM, mxSetN

  


Recommended Products

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