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

4 views (last 30 days)
darlene yen
darlene yen on 7 Nov 2017
Answered: Prachi Sikaria on 24 Sep 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

Accepted Answer

KSSV
KSSV on 7 Nov 2017
Edited: KSSV on 7 Nov 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 Comments
darlene yen
darlene yen on 8 Nov 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

Sign in to comment.

More Answers (1)

Prachi Sikaria
Prachi Sikaria on 24 Sep 2020
what is the relation of z in surf(x y z)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!