How to plot a complex function in matlab like : f(z)=sin(z)?

22 views (last 30 days)
How to plot a complex function in matlab like : f(z)=sin(z)?
z is the complex like z=x+iy

Answers (1)

John D'Errico
John D'Errico on 21 Nov 2020
Edited: John D'Errico on 21 Nov 2020
The problem is, if z is a complex variable, then so is the extension of sin(z) into the complex plane. For example...
sin(1 + i)
ans = 1.2985 + 0.6350i
And that means you are asking to plot something that has FOUR dimensions. Remember that a complex variable is itself 2 variables stuffed into one. And since we cannot easily plot in 4 dimensions (unless your own personal holodeck is working, mine is always broken, and Starfleet Command never sends the parts I need. They just tell me to call the borg for parts. You know how well that would end.)
The point is, we can plot THREE dimensional things, but even that is as a projection into the 2-d plane of your monitor.
fr = @(xr,xi) real(sin(xr + i*xi));
fi = @(xr,xi) imag(sin(xr + i*xi));
fsurf(fr,'r')
hold on
fsurf(fi,'g')
I have plotted the real and imaginary parts separately, but on the same figure. Or I might have plotted them side-by-side, using subplot. But until the borg answers my calls, that blasted holodeck still won't work. Wait, wait, the doorbell is ringi..........
  2 Comments
sasan sadeghi
sasan sadeghi on 21 Nov 2020
I tried to plot f(z)= e^z with your way , but i got Warning: Error updating FunctionSurface.,
is there another way to plot "e^z"?
Thanks in advance,

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!