User`s guide
4 Using MWArra y Classes
Example—GettinganMWArrayValuewithget
Retrieve element (2, 4) from array object A:
int[] index = {2, 4};
Object d_out = A.get(index);
System.out.println("Data read from A(2,4) is " +
d_out.toString());
When run, the example displays this output:
Data read from A(2,4) is 10
getData. This method returns a ll elements of the MWArray object. Elements
are returned in a one-dimensional array, in column-wise order. Elements
are returned as type
Object.
The prototype for the
getData method is as fo llows:
public Object getData()
Input Parameters
None
The elements of the returned array are converted according to default
conversion rules. If the underlying MATLAB array is a complex numeric
type,
getData returns the real part.
Example — Ge tting an MWArray Value with getData
Get the data from MWArray object A , casting the type from Object to int:
System.out.println("Data read from matrix A is:");
int[] x = (int[]) A.getData();
for (int i = 0; i < x.length; i++)
System.out.print(" " + x[i]);
4-46