Filter löschen
Filter löschen

Sketching a tangent plane to the given equation

3 Ansichten (letzte 30 Tage)
Keni Fernando
Keni Fernando am 14 Apr. 2021
Kommentiert: Keni Fernando am 17 Apr. 2021
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)].

Akzeptierte Antwort

Khalid Mahmood
Khalid Mahmood am 14 Apr. 2021
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 Kommentare
Isuru Prabodh Appuhamy
Isuru Prabodh Appuhamy am 15 Apr. 2021
how can I plot tangent plane in same graph
Keni Fernando
Keni Fernando am 17 Apr. 2021
how can we change the x0, y0, and z0. In ur method if i try to change those values it gives an error.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by