필터 지우기
필터 지우기

how to draw a hyperboloid?

조회 수: 55 (최근 30일)
bsd
bsd 2011년 9월 25일
댓글: Benjamin Backus 2020년 7월 22일
Hai,
I need to draw a hyperboloid in matlab. How is it I could do it?
BSD
  댓글 수: 6
Fangjun Jiang
Fangjun Jiang 2011년 9월 25일
Then you need to explain what is hyperboloid and what you want to do. I can search for hyperboloid and it gives me lots of hits. For your benefit, barely mention hyperboloid in your question is not sufficient, right?
bsd
bsd 2011년 9월 25일
hyperboloid is a three dimensional representation of a hyperbola. Just like sphere, as sphere is a three dimensional and circle is two dimensional.
BSD

댓글을 달려면 로그인하십시오.

채택된 답변

UJJWAL
UJJWAL 2011년 9월 26일
Hi BSD,
I hope the following code will help. Reply back :-
clc;
clear all;
[X,Y,Z] = meshgrid(-10:0.5:10,-10:0.5:10,-10:0.5:10);
a=1;
b=1;
c=1;
V = X.^2/a^2 + Y.^2/b^2 - Z.^2/c^2;
p=patch(isosurface(X,Y,Z,V,1)); % This is the key step. It involves getting the part of the volume corresponding to the surface defined by the equation
set(p,'FaceColor','red','EdgeColor','none');
daspect([1 1 1])
view(3);
camlight
Hope This helps..
Happy To Help
UJJWAL
  댓글 수: 2
bsd
bsd 2011년 9월 28일
It gives both the upper and lower portion. But I need only the upper portion of the hyperboloid. How to do that? Looking for your reply.
BSD
UJJWAL
UJJWAL 2011년 9월 28일
Hi BSD,
That is very easy as you just have to change the range of the x,y and z points you use in meshgrid
For getting the upper portion you just need to set z from 0:0.5:10
so in the above code just replace the meshgrid line with the following :-
[X,Y,Z] = meshgrid(-10:0.5:10,-10:0.5:10,0:0.5:10);
Hope This Helps
HAPPY TO HELP
UJJWAL

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

HAGOS EMAN
HAGOS EMAN 2019년 6월 18일
Thanking you all! Very helpful!

Fangjun Jiang
Fangjun Jiang 2011년 9월 25일
As long as you have the mathematical equation describing that hyperboloid, you should be able to generate some data and then draw it.
Take a unit sphere for example, the equation is x^2+y^2+z^2=1; If you carefully set the mesh grid for x and y, then you can calculate the corresponding value for z. Then you can use surf() to plot it.
MATLAB has the sphere() function. Here I am using it to generate the data first and then plot it. Running sphere alone can plot it too.
[x,y,z]=sphere;
surf(x,y,z)

Chaowei Chen
Chaowei Chen 2011년 9월 25일
[x,y]=meshgrid(-10:10);
r_sq=x.^2+y.^2;
z=sqrt(r_sq+1);
surf(x,y,z)
  댓글 수: 2
Bud Kelly
Bud Kelly 2018년 3월 30일
This is very clever. Thank you, I will keep it for reference. I had thought that you needed to purchase Symbolic Math Toolbox to plot 3D explicit functions, but now I am encouraged. Thanks.
Benjamin Backus
Benjamin Backus 2020년 7월 22일
That doesn't look like an ellipsoid to me. The 3rd line should rather be:
z=sqrt(200 - r_sq);
in order to have an ellipsoid of equation x^2 + y^2 + z^2 = 200 (200 because x and y have magnitude 10)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by