How to plot a 3d 'U' shape in MATLAB parallel to XY plane?

2 件のコメント

Dcember
Dcember 2016 年 11 月 23 日
Hope it helps:
[y,z]=meshgrid(linspace(-10,10));
x=y.^4;
surf(x,y,z)
xlabel('x')
ylabel('y')
zlabel('z')
shraddha s
shraddha s 2016 年 11 月 23 日
Thanks for replying. I want to display simple U shape in 3D(not meshgrid) which will be parallel to XY plane. How to do that? I tried to plot a parabola but it does not look like U.

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

 採用された回答

Star Strider
Star Strider 2016 年 11 月 23 日

1 投票

Try this:
x = linspace(-pi*0.49, pi*0.49);
y = abs(tan(x));
z = 5*ones(size(x));
figure(1)
plot3(x, y, z, 'LineWidth',2)
grid on
producing:

4 件のコメント

shraddha s
shraddha s 2016 年 11 月 24 日
Thanks a lot ! This is what I was looking for. I just want to change its facing. How can I rotate it ?
Star Strider
Star Strider 2016 年 11 月 24 日
My pleasure!
The easiest way is to use the rotate function. You will have to experiment with it to get the result you want.
You can also change its height above the (x,y) plane by substituting the ‘5’ multiplier to the ones call with the value you want.
shraddha s
shraddha s 2016 年 11 月 24 日
Thanks!
Star Strider
Star Strider 2016 年 11 月 24 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLabels and Styling についてさらに検索

タグ

質問済み:

2016 年 11 月 23 日

コメント済み:

2016 年 11 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by