Sketching a tangent plane to the given equation

조회 수: 5 (최근 30일)
Keni Fernando
Keni Fernando 2021년 4월 14일
댓글: Keni Fernando 2021년 4월 17일
How to plot a tangent plane to a given equation with a range.
Example question is as follows,
z=sqrt(5-x^2-y^2) in the regions [-sqrt(5/2)<=x<=sqrt(5/2)], [-sqrt(5/2)<=y<=sqrt(5/2)]
and sketch the tangent plane to Z at point [sqrt(5)/2,sqrt(5)/2,sqrt(5/2)].

채택된 답변

Khalid Mahmood
Khalid Mahmood 2021년 4월 14일
Lim=sqrt(5/2); inc=2*Lim/99; %100 incremets
[X,Y] = meshgrid(-Lim:inc:Lim);
ZFunc= @(x,y) real(sqrt(5-x.*x-y.*y));
Z=ZFunc(X,Y);
[fx,fy] = gradient(Z,inc); %gradient approximates derivative of Z=f(x,y) with same finite length as inc
x0 = Lim;
y0 = Lim;
comp = (X == x0) & (Y == y0);
indt = find(comp);
fx0 = fx(indt);
fy0 = fy(indt);
z0=x0;
Z_tanSurf = @(x,y) ZFunc(x0,y0) + fx0*(x-x0) + fy0*(y-y0); %tangent plane function
Zt=Z_tanSurf(X,Y);
subplot(2,2,1);surf(X,Y,Z,'EdgeAlpha',0.7,'FaceAlpha',0.9)
title('given 3D surface')
%hold on
subplot(2,2,2);surf(X,Y,Zt); title('Tagent Plane');
subplot(2,2,3);plot3(x0,y0,z0,'r*'); title('Required point');
subplot(2,2,4);surf(X,Y,Z,'EdgeAlpha',0.7,'FaceAlpha',0.9); title(['3d plot, tagent Plane to plot at given point' mat2str([x0,y0,z0])]);
hold on;surf(X,Y,Zt);plot3(x0,y0,ZFunc(x0,y0),'r*')
  댓글 수: 3
Isuru Prabodh Appuhamy
Isuru Prabodh Appuhamy 2021년 4월 15일
how can I plot tangent plane in same graph
Keni Fernando
Keni Fernando 2021년 4월 17일
how can we change the x0, y0, and z0. In ur method if i try to change those values it gives an error.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by