4 Using MWArra y Classes
System.out.println(A.toString());
Here is the complex array that is displayed:
2.0000 + 6.0000i 3.0000 + 5.0000i 4.0000 + 14.0000i
8.0000 + 7.0000i 9.0000 + 1.0000i 10.0000 + 23.0000i
14.0000 + 1.0000i 15.0000 + 1.0000i 16.0000 + 9.0000i
Now, use get and getImag to read the real and imaginary parts of the element
at index (
2, 3):
int[] index = {2, 3};
System.out.println("The real part of A(2,3) = " +
A.get(index));
System.out.println("The imaginary part of A(2,3) = " +
A.getImag(index));
When run, the example displays this output:
The real part of A(2,3) = 10.0
The imaginary part of A(2,3) = 23.0
getImagData. This method returns a one-dimensional MWNumericArray
containing a copy of the imaginary data in the underlying M ATLAB a rray.
The prototype for the
getImagData method is as follows:
public Object getImagData()
getImagData
returns the array of elements in column-wise order. The
elements are converted according to default conversion rules.
Example — Getting Data from a Complex Array
Using the same array as in the example for “getImag” on page 4 -81, get the
entire contents of the complex array:
int[] index = {2, 3};
double[] x;
4-82
Komentarze do niniejszej Instrukcji