Plot 2 Tangent Lines in a function

6 visualizaciones (últimos 30 días)
Fernando Moreno
Fernando Moreno el 17 de Nov. de 2021
Respondida: Alamanda Ponappa Poovaya el 23 de Nov. de 2021
Im having problems while doing a function because I want to plot 2 tangent lines in x=1 and x=5 but Im not sure how to plot it, this is my current code
figure()
yline(0)
xline(0)
hold on
syms f(x)
f=15000*exp(x)^(-.6286*x)
f = 
diff(f)
ans = 
fplot (x,f, [0,10])

Respuestas (1)

Alamanda Ponappa Poovaya
Alamanda Ponappa Poovaya el 23 de Nov. de 2021
Hi
Please have a look at the code snippet below. It calculates the tanget at points 1 and 5 and plots the tangents. Keep in mind that the tangent at 5 overlaps with your xline(0) hence it is not visually distinguishable
figure()
yline(0)
xline(0)
hold on
syms f(x)
f=15000*exp(x)^(-.6286*x);
fplot (x,f, [0,10])
dy(x)=diff(f,x);
% y = mx + c
% at 1
m = subs(dy,x,1);
m = double(m);
y = double(subs(f,x,1));
c = y - m*1;
syms t(x)
t = m*x + c;
fplot (x,t, [0,10])
% at 5
m = subs(dy,x,5);
m = double(m);
y = double(subs(f,x,5));
c = y - m*5;
syms t(x)
t = m*x + c;
fplot (x,t, [0,10])

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by