Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Complex number visualisation when imaginary part is null in MATLAB

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.

like image 843
Nicolás Torresa Avatar asked Sep 23 '13 18:09

Nicolás Torresa


People also ask

How do you show imaginary parts in MATLAB?

Y = imag( Z ) returns the imaginary part of each element in array Z .

How do you check if a number is imaginary in MATLAB?

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.

How do you display real part of complex numbers in MATLAB?

Description. X = real( Z ) returns the real part of each element in array Z .

How do you call an imaginary number in MATLAB?

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.


1 Answers

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.

like image 137
Dennis Jaheruddin Avatar answered Sep 29 '22 09:09

Dennis Jaheruddin