MATLAB Answers

0

how to draw a 3d surface of exp(x+iy)

Asked by Lvfan LIU on 11 Sep 2019
Latest activity Commented on by Rik
on 11 Sep 2019
exp(z)=exp(x)*(cosy+i*siny)

  2 Comments

The result is a complex number: what do you want on the axes?
x,y,abs(exp(z))
x,y,real(exp(z))
x,y,imag(exp(z))
Rik
on 11 Sep 2019
z_val=@(x,y) log(exp(x).*(cos(y)+1i*sin(y)));
[X,Y]=ndgrid(linspace(-3*pi,3*pi,100));
Z=z_val(X,Y);
figure
ax1=subplot(1,2,1);
surf(X,Y,real(Z));
title('real part')
ax2=subplot(1,2,2);
surf(X,Y,imag(Z));
title('imaginary part')
Then you can link the axes with linkprop.

Sign in to comment.

Tags

2 Answers

Answer by Bjorn Gustavsson on 11 Sep 2019
Edited by Bjorn Gustavsson on 11 Sep 2019

Have a look at the dcolor submission to the file exchange. That should give you a good starting point for doing this.
There are all sorts of combinations to try to convey the complex-valued surface. You could put the angle as the colour for your surface and the magnitude as the z-value to the plain surf call
[x,y] = meshgrid(linspace(-2,2,1001));
z = log(exp(x).*(cos(y)+i*sin(y)));
surf(x,y,abs(z),angle(z)),shading flat
, or the other way around, or the real and imaginary parts. When it comes to this type of plotting the best way is to try all sort of combinations you can imagine and see which works best for your purposes.
HTH

  0 Comments

Sign in to comment.


Answer by Fabio Freschi on 11 Sep 2019

Suppose that you want to plot the magnitude of the exp(z)
% setup the range of your plot in x and y (-2,2) and the resolution (20 points)
x = linspace(-2,2,20);
y = linspace(-2,2,20);
% create a regular grid (X and Y are 2d matrices)
[X,Y] = meshgrid(x,y);
% evaluate your function (note that the imaginary unit is 1i, note also the operator .*)
expZ = exp(X).*(cos(Y)+1i*sin(Y))
% now the plot (here the abs, use real or imag as you like)
figure
surf(X,Y,abs(expZ));
% label as desired
xlabel('x coordinate');
ylabel('y coordinate');
zlabel('exp(Z)');

  0 Comments

Sign in to comment.