Plotting a nice function

4 visualizaciones (últimos 30 días)
Sergio Manzetti
Sergio Manzetti el 14 de Jun. de 2021
Respondida: Reshma Nerella el 17 de Jun. de 2021
Hi, I have prepared the given code for the following function:
syms r x y k z
x = -10:0.3:10;
y = x';
z = x + 1i*y;
scale = 1;
J = besselj(5,r)
u = symsum(1i.^(-k).*J.*exp(1i*k*x),k,-5,5)
surf(r,x,imag(u))
But the plot doesn't work, I only get z must be a scalar or a vector. In fact, I have my doubts about the plotting command, because this is a polar function shown in the image, and not a cartesian function.
How I can get this plot similar to this:
?
Thanks!

Respuestas (1)

Reshma Nerella
Reshma Nerella el 17 de Jun. de 2021
Hi,
The 3rd argument(Z) to the surf function should be a matrix with atleast 2 rows and 2 columns.
In this line of code,
surf(r,x,imag(u))
imag(u) is 1x67 sym, hence you are getting the error.
For more information on the input arguments and surf function, refer to the documentation: surf

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by