External Interfaces/API    

Manipulating Multidimensional Numerical Arrays

Multidimensional numerical arrays were a new data type introduced in MATLAB 5. For a discussion of the features of multidimensional numerical arrays and the built-in functions MATLAB provides to manipulate them, refer to the MATLAB topic, Multidimensional Arrays. Like all other data types in MATLAB, arrays can be passed into and out of MEX-files written in C. You can manipulate multidimensional numerical arrays by using mxGetData and mxGetImagData to return pointers to the real and imaginary parts of the data stored in the original multidimensional array.

This example takes an N-dimensional array of doubles and returns the indices for the nonzero elements in the array.

Entering a sample matrix at the MATLAB prompt gives

This example determines the position of all nonzero elements in the matrix. Running the MEX-file on this matrix produces


 Handling 8-,16-, and 32-Bit Data Handling Sparse Arrays