Can someone explain to me how to code the Tangent line and Normal line
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Echo Lei
el 4 de Oct. de 2022
Comentada: Echo Lei
el 4 de Oct. de 2022
2 comentarios
Davide Masiello
el 4 de Oct. de 2022
Editada: Davide Masiello
el 4 de Oct. de 2022
Your code seems to be correct, what is the problem?
Respuesta aceptada
Más respuestas (1)
Davide Masiello
el 4 de Oct. de 2022
Editada: Davide Masiello
el 4 de Oct. de 2022
syms x m b yt
f(x) = 3^x+3*x+2; % Function
m = diff(f,x) % Slope of tangent line
b = f-m*x; % Intercept of tangent line
x0 = randi([-5 5]); % Random point x
b = subs(f,x0)-subs(m,x0)*x0; % Intercept value at random point % Redefine x as symbolic variable
yt(x) = subs(m,x0)*x+b % Tangent line equation at random point
fplot(x,f(x)) % Plot function
hold on
fplot(x,yt(x),'r') % Plot tangent
plot(x0,subs(yt,x0),'ok') % Plot point of tangency
You can use the same procedure for the normal line.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!