MATLAB: Only the real part of the complex number is displayed

imaginary numbersMATLAB

When I have a complex number as an output, Mtalab either doesn't display the number or only shows the real part. Any idea how can I fix that

Best Answer

I believe you're using the bank display format (format bank) which does not show the imaginary parts of numbers. What would $4.56i represent?
A = [1 -2; -3 4]
format
sqrt(A) % shows imaginary part in default format, format short
ans = 2×2
1.0000 + 0.0000i 0.0000 + 1.4142i 0.0000 + 1.7321i 2.0000 + 0.0000i
format bank
sqrt(A) % shows in bank format
ans = 2×2
1.00 0.00 0.00 2.00
Related Question