How I use a parabola in the xy-plane as base curve for the cylinder?

2 ビュー (過去 30 日間)
Besim Helic
Besim Helic 2015 年 4 月 22 日
コメント済み: Roger Stafford 2015 年 4 月 23 日
Hi to everyone, I'm really new how to this site so to MatLab, too.
So here is my problem: Here is the code to create a cylinder where my base in the xy-plane one ellipse is:
m = 20; n = 50; u = linspace(0, 1, m); v = linspace(0, 2*pi, n); [U, V] = meshgrid(u,v);
a = 3; b = 5;
X = cos(V)*a + U*0; Y = sin(V)*b + U*0; Z = V*0 + U*10;
s = surf(X, Y, Z);
How can I now edit/modify my code to use parabola or hyperbola as base curve?
Thanks.

採用された回答

Roger Stafford
Roger Stafford 2015 年 4 月 22 日
For a hyperbola, x^2/a^2-y^2/b^2 = 1, replace the two lines for X and Y by:
X = a*cosh(V);
Y = b*sinh(V);
For a parabola, y = a*x^2, use:
X = V-pi;
Y = a*X.^2;
  2 件のコメント
Besim Helic
Besim Helic 2015 年 4 月 23 日
Thank you very much, this works perfect for parabola (!), but not for hyperbola too. The result is than only one line in xy-plane.
Roger Stafford
Roger Stafford 2015 年 4 月 23 日
To get a better hyperbola also change v:
v = linspace(-1,1,n);
This shows only one of its two branches. To get the other branch write
X = -a*cosh(V);
Y = -b*sinh(V);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by