Hello! Could you help me with an issue? I'm trying to plot this figure:
u = 0:pi/5:4*pi;
v = 0:0.05:1;
X = v.*cos(u)-(1/2).*(v.^2).*cos(2*u);
Y = -v.*sin(u)-(1/2).*(v.^2).*sin(2*u);
Z = 4.*(v.^(3/2)).*cos(3.*u/2)/3;
figure('Color','w')
clf
s = surf(X,Y,Z, ...
'LineStyle','none', ...
'FaceLighting','gouraud', ...
'FaceColor','interp');
But MATLAB keeps telling me that Z must be a matrix, not a scalar or vector. How can I solve this problem?
Thanks for your help!

 採用された回答

Star Strider
Star Strider 2015 年 3 月 14 日

1 投票

Solve it with the magic of meshgrid:
u = 0:pi/5:4*pi;
v = 0:0.05:1;
[u,v] = meshgrid(u,v);
The rest of your code remains unchanged, and it produces an interesting looking plot.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Objects についてさらに検索

製品

タグ

質問済み:

2015 年 3 月 14 日

回答済み:

2015 年 3 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by