MATLAB Application Program Interface Reference Help Desk

mxGetNumberOfDimensions

Purpose

Get the number of dimensions

C Syntax

Arguments

array_ptr

Pointer to an mxArray.

Returns

The number of dimensions in the specified mxArray. The returned value is always 2 or greater.

Description

Use mxGetNumberOfDimensions to determine how many dimensions are in the specified array. To determine how many elements are in each dimension, call mxGetSize.

Examples

Consider a MEX-file named CountDim that calls mxGetNumberOfDimensions to determine how many dimensions are in the first input argument.

In MATLAB, create a three-dimensional mxArray named td. Then pass td as an argument to CountDim

Since td is a 3-dimensional mxArray, CountDim creates a 2-by-2-by-2 mxArray. If td had been a 4-dimensional mxArray, CountDim would have created a 2-by-2-by-2-by-2.

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

See Also

mxSetM, mxSetN



[ Previous | Help Desk | Next ]