Ploting, Imaginary parts of complex X and/or Y arguments ignored

4 views (last 30 days)
I have question.
I want to plot function plot(x,f(x)), but f(x) has some complex values for some values of x. When I want to plot this function, I receive report ''Imaginary parts of complex X and/or Y arguments ignored''.
How to solve this problem, because I want to plot f(x) for all values, not just real?
Thank you very much for any answer.
Regards,
Nikola

Answers (2)

Walter Roberson
Walter Roberson on 23 Feb 2012
What would you like the output to look like at the f(x) that are imaginary?
plot() has not ignored any points: it has done the equivalent of
plot(x, real(f(x)))
on your behalf.
Perhaps you would like something such as
fx = f(x);
plot(x, real(fx), 'b', x, imag(fx), 'r');
  2 Comments
Walter Roberson
Walter Roberson on 8 Oct 2017
'b' and 'r' are color codes, blue and red, so that the real and imaginary parts can be distinguished at a glance.

Sign in to comment.


Sean de Wolski
Sean de Wolski on 23 Feb 2012
You can either add another dimension to yuor plot (another line or plot3) and extract the imaginary parts (using imag()) or you can convert to real using abs())

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!