How can I custom cylinder rotate axis?

8 ビュー (過去 30 日間)
ali alizadeh
ali alizadeh 2021 年 9 月 3 日
編集済み: Tuan 2023 年 3 月 23 日
Hi
I have a 2D graph and I want make it 3D via cylinder. but cylender rotating it about x-axis.
is there anyway to change this? for example rotate about y-axis
  1 件のコメント
Matt J
Matt J 2021 年 9 月 3 日
but cylender rotating it about x-axis.
I assume you mean the z-axis.

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

採用された回答

Matt J
Matt J 2021 年 9 月 3 日
編集済み: Matt J 2021 年 9 月 4 日
Another approach:
[Xq,Zq]=ndgrid(linspace(-3,3,100));
[~,Rq]=cart2pol(Xq,Zq);
func=@(r) sin(r)./r; %The 1D profile
x=linspace(0,3,100);
y=func(4*x);
Yq=interp1(x,y,Rq); %rotated about Y-axis
surf(Xq,Yq,Zq,'EdgeColor','none')
xlabel 'X', ylabel 'Y', zlabel 'Z'
  4 件のコメント
ali alizadeh
ali alizadeh 2021 年 9 月 4 日
編集済み: Matt J 2021 年 9 月 4 日
sorry mr Matt J
I attach my data. may you plot it?
Please plot this datas, with rotating graph about y-axis.
data=load('5.csv');
x=data(:,2);
y=data(:,1); y=y/max(y);
a=3*max(abs(x));
[Xq,Zq]=ndgrid(linspace(-a,a,2000));
[~,Rq]=cart2pol(Xq,Zq);
Yq=interp1(x,y,Rq); %rotated about Y-axis
surf(Xq,Yq,Zq,'EdgeColor','none','FaceAlpha',0.6)
xlabel 'X', ylabel 'Y', zlabel 'Z'
Matt J
Matt J 2021 年 9 月 4 日
I 've added the necessary code to your last comment and run it.

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

その他の回答 (1 件)

Matt J
Matt J 2021 年 9 月 3 日
編集済み: Matt J 2021 年 9 月 3 日
For example,
[X,Z,Y] = cylinder(2+cos(0:pi/10:2*pi));
surf(X,Y,Z)
xlabel 'X', ylabel 'Y', zlabel 'Z'
  4 件のコメント
ali alizadeh
ali alizadeh 2021 年 9 月 4 日
Many Thanks. it's nicly works.
Tuan
Tuan 2023 年 3 月 23 日
編集済み: Tuan 2023 年 3 月 23 日
Hi, I have just the same question, but this time around y-axis, to create a cup with 2 parabol, can you help me with the code cause im stuck with all the tutorial online

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

カテゴリ

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