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

C Syntax

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

Fortran Syntax

mwSize mxGetN(pm)
mwPointer pm

Arguments

pm

Pointer to an mxArray

Returns

The 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 refbook subdirectory of the examples directory.

Additional examples:

Fortran Examples

See matdemo2.F in the eng_mat subdirectory of the examples directory for a sample program that illustrates how to use this routine in a Fortran program.

See Also

mxGetM, mxGetDimensions, mxSetM, mxSetN

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS