How to plot elliptic function (x,y,z) in MATLAB

조회 수: 4 (최근 30일)
Jong Hyun Lee
Jong Hyun Lee 2022년 3월 26일
답변: Chanchal Dass 2022년 9월 23일
I want to plot a elliptic function (x^2+y^2+z=16) on matlab with limits 0<=x<=2 and 0<=y<=2

답변 (3개)

Voss
Voss 2022년 3월 26일
% 0<=x<=2 and 0<=y<=2
x = linspace(0,2,20);
y = linspace(0,2,20);
[X,Y] = meshgrid(x,y);
% x^2+y^2+z=16
Z = 16-X.^2-Y.^2;
surf(X,Y,Z);
grid on
view([60 30]);
xlabel('x')
ylabel('y')
zlabel('z')
  댓글 수: 2
Jong Hyun Lee
Jong Hyun Lee 2022년 3월 26일
thanks
Voss
Voss 2022년 3월 26일
You're welcome!

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


Sam Chak
Sam Chak 2022년 3월 26일
편집: Sam Chak 2022년 3월 26일
Please check if it looks like this:
meshpoints = 41;
Lb = 0; % lower bound
Ub = 2; % upper bound
step = (Ub - Lb)/(meshpoints - 1);
[x, y] = meshgrid(Lb:step:Ub, Lb:step:Ub);
z = 16 - (x.^2 + y.^2); % the surface equation
surf(x, y, z)
view([135 23]);
  댓글 수: 3
Sam Chak
Sam Chak 2022년 3월 26일
편집: Sam Chak 2022년 3월 26일
Meshpoints specifies the number of points and meshgrid function creates the number of points between Lower bound and the Upper bound in the x- and y-axes. If the number of mesh points is too small, it will create a very coarse (rough) texture. If the number of mesh points is too big, it will create a very dense (thick) texture. Adjust the number and you will experience it.
The surf function creates the surface plot. You can also use the mesh function, if you want to create the surface that has solid edge colors but no face colors.
Jong Hyun Lee
Jong Hyun Lee 2022년 3월 26일
I see, thanks a lot

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


Chanchal Dass
Chanchal Dass 2022년 9월 23일
Is it an elliptic surface?

카테고리

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