Z is not matrix for surf(X,Y,Z)

6 visualizaciones (últimos 30 días)
darlene yen
darlene yen el 7 de Nov. de 2017
Respondida: Prachi Sikaria el 24 de Sept. de 2020
I am trying to plot surf(X,Y,Z) but my Z is not a matrix.
TH = [0:0.05*pi:2*pi ];
R = [0:0.5:20];
[X,Y] =pol2cart(TH,R);
[X,Y] = meshgrid(X,Y)
Z = (abs((sqrt(2)/(81*sqrt(pi))).*(6.*R-R.^2).*exp(-R./3).*cos(TH))).^2
Im hoping someone can look over my code and help me out. Thanks

Respuesta aceptada

KSSV
KSSV el 7 de Nov. de 2017
Editada: KSSV el 7 de Nov. de 2017
TH = [0:0.05*pi:2*pi ];
R = [0:0.5:20];
[X,Y] =pol2cart(TH,R);
[X,Y] = meshgrid(X,Y) ;
[R,TH] = meshgrid(R,TH) ;
Z = (abs((sqrt(2)/(81*sqrt(pi))).*(6.*R-R.^2).*exp(-R./3).*cos(TH))).^2 ;
figure
surf(R,TH,Z)
figure
surf(X,Y,Z)
  2 comentarios
darlene yen
darlene yen el 7 de Nov. de 2017
thanks
darlene yen
darlene yen el 8 de Nov. de 2017
for some reason, the code doesn't run out to be desired answer. the dimensions are all correct but not the value.
for original function is

Iniciar sesión para comentar.

Más respuestas (1)

Prachi Sikaria
Prachi Sikaria el 24 de Sept. de 2020
what is the relation of z in surf(x y z)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects 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