Struggling to plot a complex function using the mesh command.

20 次查看(过去 30 天)
Hi,
I need help with making a complex mesh of a function. The function is simply sin(a+a*pi/2) but a is a complex number.
I want to make the domain from -360i to 360i in the complex axis and -360 to 360 in the real axis. With a step of 1 in each. Meaing I will have 721x721 resutls to plot.
upper = 360;
dx = 1;
x = -upper:dx:upper;
z = zeros(length(x),length(x));
y = zeros(1, length(x));
for i = 1:length(x)
for count = 1:length(x)
z(i,count) = complex(x(i),x(count));
end
end
y = sind(z+z.*pi()./2);
Above is the code I used to get the results for the function and stored it in y. x is every point along the real axis, and z is everypoint on the real-imagainary plane.
Now I'm not sure how I should plot this using the mesh function. Of course there is the first problem that plotting this would require 4 dmentions; but I'm happy to take the absolute value/real value/ complex value to limit the answer to 3d. But, I'm not sure how to polt any of these graphs, and ideal plot them all at the same time.
mesh(x , x*j ? , ?)
Thank you in advanced.
  2 个评论
KSSV
KSSV 2020-7-23
The function has a, and a values are defined......how you can take values from -2*pi to 2*pi. ?
Wojciech Kalinowski
That's my bad, the a values where an examples. in reality the a having a fixed set was just me trying to explain the plot in the cooridnet system. So that through every real number, taking a line pependicular to the real axis, there exists a user defined amount of complex numbers. Hence a = 0, i, -i, 1+i, ect.
Sorry that was my bad wording. Will remove the finite set from the question.

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2020-7-23
Try something like this:
ar = linspace(-2*pi,2*pi,10) ;
[r, c] = meshgrid(ar) ;
a = r+1i*c ;
y = sin(a+a*pi/2) ;
surf(real(a),imag(a),abs(y))
  3 个评论
Wojciech Kalinowski
I have, but to have a good resolution to confirm the expected shaped I had to take n to 1000 over a small range. For all other purpose ~200 is fine. Once again thank you.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by