From: noveen on
If i have an array (say 2 by 2 or 2 by 6 etc) how do i check if each of the elements are real or complex. I am looking for something which checks each element of the array and returns the array as it is if all elements are real and if any element is complex, it just picks up the real part and rejects the imaginary part. Basically, i want an array of realnumbers to work with.
From: Wayne King on
"noveen " <noveenkapur(a)yahoo.co.in> wrote in message <i099rf$p9p$1(a)fred.mathworks.com>...
> If i have an array (say 2 by 2 or 2 by 6 etc) how do i check if each of the elements are real or complex. I am looking for something which checks each element of the array and returns the array as it is if all elements are real and if any element is complex, it just picks up the real part and rejects the imaginary part. Basically, i want an array of realnumbers to work with.

Hi

x = randn(2,2)+1j*randn(2,2);
real(x)
imag(x)

Wayne
From: us on
"noveen " <noveenkapur(a)yahoo.co.in> wrote in message <i099rf$p9p$1(a)fred.mathworks.com>...
> If i have an array (say 2 by 2 or 2 by 6 etc) how do i check if each of the elements are real or complex. I am looking for something which checks each element of the array and returns the array as it is if all elements are real and if any element is complex, it just picks up the real part and rejects the imaginary part. Basically, i want an array of realnumbers to work with.

a hint:

help isreal;

us