Struggling to plot a complex function using the mesh command.

27 visualizaciones (últimos 30 días)
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 comentarios
KSSV
KSSV el 23 de Jul. de 2020
The function has a, and a values are defined......how you can take values from -2*pi to 2*pi. ?
Wojciech Kalinowski
Wojciech Kalinowski el 23 de Jul. de 2020
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.

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 23 de Jul. de 2020
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 comentarios
KSSV
KSSV el 23 de Jul. de 2020
Increase the number in linspace.
n = 100 ;
ar = linspace(-2*pi,2*pi,n) ;
Wojciech Kalinowski
Wojciech Kalinowski el 23 de Jul. de 2020
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by