Tangent line to a curve at a given point
Afficher commentaires plus anciens
Hy, I want to plot tangent line for function given by one point.
I tried to solve this problem but didnt work well Someone can me help me,pls
syms x
func = -2*x^2+4;
x0 = 1;
% f(x)'= -4*x
m=diff(func)
% m == f(x0)'= -4*x0
fdx = inline(m, 'x');
fdx(x0)
% x == (x - x0)
xX =(x - x0)
% c == f(x0)
fx = inline('-2*x^2+4', 'x');
c = fx(x0)
ezplot(x)
hold on
% y = m*x + c
y=m*xX+c;
ezplot(y)
1 commentaire
Jan
le 6 Oct 2013
"Didn't work well" is a DON'T in a forum. Do not let us guess the problems, but explain them to save the time of the readers. The less the readers have to guess, the more likely is a matching answer.
Réponse acceptée
Plus de réponses (1)
Varun Kumar
le 2 Nov 2019
0 votes
2*(x^(1/2)) 1,2
Catégories
En savoir plus sur Common Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!