User`s guide
4 Using MWArra y Classes
The prototype for the numberOfElements method is as follows:
public int numberOfElements()
Input Parameters
None
Example — Getting the Number of MWArray Elements
Display the number of elements in array object A:
System.out.println("Matrix A has " + A.numberOfElements() +
" elements");
When run, the example displays this output:
Matrix A has 18 elements
Methods to Get and Set Data in the MWArray
Use these methods to get and set v alues in an object of class MWArray or any o f
its child classes.
Method Description
“get” on page 4-45 Returns the element at the specified o ne-based
offset or index array as an
Object.
“getData” on page
4-46
Returns a one-dimensional array containing a copy
of the data in the underlying MATLAB array. The
array is in column-wise order.
“set” on page 4-47 Replaces the element at the s pecified o ne -based
offset, or index array, in this array with the s pecified
element.
“toArray” on page
4-48
Returns an array containing a copy of the data in
the underlying MATLAB array. The returned array
has the same dimensionality as the MATLAB array.
4-44