Hello, I have been trying to surf two parallel circles but data dimensions don't match and I don't know why. Any help would be nice. Thank you, Omar

1 回表示 (過去 30 日間)
radius = 1; center = [0 0]; theta = linspace(0,2*pi); X = center(1)+radius.*cos(theta); X=[X;X]; Y = center(2)+radius.*sin(theta); Y=[Y;Y]; Z = zeros(size(X));Z=[Z;Z];Z(2,:)=1;surf(X,Y,Z); hold on;

採用された回答

elias GR
elias GR 2016 年 10 月 6 日
Furthermore, surf is not the right command to do what you want. Try the following instead:
fill3(X(1,:),Y(1,:),Z(1,:),'r')
hold on
fill3(X(2,:),Y(2,:),Z(2,:),'b')
  2 件のコメント
Omar Rashed
Omar Rashed 2016 年 10 月 6 日
Thanks, I realised surf was wrong as well after it gave me a hollow cylinder. But I didn't get two circles when I used your answer, it gave me one, even after correcting the last line
Omar Rashed
Omar Rashed 2016 年 10 月 6 日
Never mind, I found the issue, thank you so much

サインインしてコメントする。

その他の回答 (2 件)

Massimo Zanetti
Massimo Zanetti 2016 年 10 月 6 日
編集済み: Massimo Zanetti 2016 年 10 月 6 日
You doubled Z, delete the
Z=[Z;Z];
line and everything will be fine.

elias GR
elias GR 2016 年 10 月 6 日
編集済み: elias GR 2016 年 10 月 6 日
Erase Z=[Z;Z]; This is not needed because X already have 2 rows and size(X)=[2 100]

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by