Using the C++ Math Library    

Determining Array Size

You can determine the size of an array in several ways:

Using the size() Routine

This version of size() returns the number of rows and columns in one or more separate arrays. Because it returns the dimensions as MATLAB scalar arrays, size() is consistent with the rest of the interface. However, because it returns arrays, it is far slower and uses more storage than the overloaded version of size() that returns dimensions as integers.

Using the Overloaded size() Routine

The overloaded version of size() returns array dimensions as integers rather than scalar arrays. This version of size() is efficient and easy to use; however, it only supports two dimensional arrays. It has been superseded by the member function, mwArray::Size(), which works for multidimensional arrays.

Using the mwArray Size() Member Functions

The mwArray object supports several member functions that returns array dimensions as integers rather than scalar arrays. These member functions are the most efficient way to compute the dimensions of an array.

The following examples show the various ways to determine array dimensions using these member functions.

mwArray EltCount() Member Function

In addition to the size member functions, the mwArray object includes a member function, named EltCount(), that returns the number of elements in the array, determined by the product of the length of each dimension:


 Converting Data to MATLAB Arrays Indexing into Arrays