フィルターのクリア

Drawing a hyperboloid with polar coordinates

8 ビュー (過去 30 日間)
Szabolcs Simon-Guth
Szabolcs Simon-Guth 2021 年 11 月 5 日
コメント済み: Mathieu NOE 2021 年 11 月 8 日
Hi all!
I have received the following problem to solve:
Draw the surface of the hyperboloid with the equation:
when
Also, the polar coordinates for x and y must be used, i.e.:
I have converted the equation of the hyperboloid so that it became:
I could then express z as:
I have the following code so far:
r = linspace(0,1,21);
a = linspace(0,2*pi,63);
[R,A] = meshgrid(r,a);
X = R.*cos(a);
Y = R.*sin(a);
Z = square((R.^2)-1);
surf(X,Y,Z);
axis equal
However, when ever I run the program I get a cylinder instead. I think the problem might be that the values of z should be between -3 and 3, however I do not know how to express this in the code. I would appricate any help that I get. Thank you for everyone in advance!

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 11 月 5 日
hello
you have to start from z and then compute r and not vice versa
also square root function is sqrt and not square
z = linspace(-3,3,21);
a = linspace(0,2*pi,63);
[Z,A] = meshgrid(z,a);
R = sqrt((Z.^2)+1);
X = R.*cos(A);
Y = R.*sin(A);
surf(X,Y,Z);
axis equal
  2 件のコメント
Szabolcs Simon-Guth
Szabolcs Simon-Guth 2021 年 11 月 5 日
Alright! Thank you very much for the help! I really appreciate it. I'm new to MATLAB and did not think of doing it the other way around. Much obliged! :)
Mathieu NOE
Mathieu NOE 2021 年 11 月 8 日
My pleasure !

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

その他の回答 (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