Problem with drawing a hyperboloid

조회 수: 2 (최근 30일)
Viktor Karlsson
Viktor Karlsson 2021년 5월 28일
답변: DGM 2021년 5월 28일
Hello,
I wrote the following code:
r=linspace(-3,3,21);
theta=linspace(0,2*pi,63);
m = 1
[R,THETA]=meshgrid(r,theta);
X=R.*cos(THETA);
Y=R.*sin(THETA);
Z = R;
C = (X.^2 + Y.^2 - Z.^2).^m;
surf(X,Y,Z,C)
axis equal
colormap jet
It becomes a cone-like hyperboloid instead, and I can not figure out where I am getting it wrong.
Any help is appreciated!
Thanks in advance.

답변 (1개)

DGM
DGM 2021년 5월 28일
You get a simple bicone because
Z = R;
and the colormapping looks random because
C = (X.^2 + Y.^2 - Z.^2).^m;
is essentially zero (it's just a collection of rounding errors, really), since
Z^2 = R^2
R^2 = X^2+Y^2
I'm not really sure what you're intending, but that's why you're getting what you get.

카테고리

Help CenterFile Exchange에서 Orange에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by