Effacer les filtres
Effacer les filtres

Sketching a tangent plane to the given equation

3 vues (au cours des 30 derniers jours)
Keni Fernando
Keni Fernando le 14 Avr 2021
Commenté : Keni Fernando le 17 Avr 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)].

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by