In MATLAB R2012:
>> rand(3) ; ans(1,1)=1+i
ans =
1.0000 + 1.0000i 0.5060 0.9593
0.7513 0.6991 0.5472
0.2551 0.8909 0.1386
But in R2013:
>> rand(3) ; ans(1,1)=1+i
ans =
1.0000 + 1.0000i 0.9134 + 0.0000i 0.2785 + 0.0000i
0.9058 + 0.0000i 0.6324 + 0.0000i 0.5469 + 0.0000i
0.1270 + 0.0000i 0.0975 + 0.0000i 0.9575 + 0.0000i
How can I fix it?
Regards.
Y = imag( Z ) returns the imaginary part of each element in array Z .
To check whether each element of an array A is real, use A == real(A) . isreal(complex(A)) always returns false , even when the imaginary part is all zeros. ~isreal(x) detects arrays that have an imaginary part, even if it is all zeros.
Description. X = real( Z ) returns the real part of each element in array Z .
You can use i to enter complex numbers. You also can use the character j as the imaginary unit. To create a complex number without using i and j , use the complex function.
Without having the option to try, I can only guess that you may want to play around with the format.
My best bet would be format shortg, it may hide the imaginary part or simply make it less distracting:
rand(3) ; ans(1,1)=1+i
format shortg
rand(3) ; ans(1,1)=1+i
Yes that is shortg instead of short. It tries not to show irrelevant zeros and decimals.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With