MATLAB Application Program Interface Reference Help Desk

mxGetN

Purpose

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

Arguments

array_ptr

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 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 mxGetSize.

If array_ptr points to a sparse mxArray, mxGetN still returns the number of columns, not the number of occupied columns.

Examples

Find the total number of elements in an mxArray:

For an additional example, see mxGetN.c in the mx subdirectory of the examples directory.

See Also

mxGetM, mxGetNumberOfDimensions, mxSetM, mxSetN



[ Previous | Help Desk | Next ]