
How can I change the code to get a tangent in the graph
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
syms x y
f(x)=-(sin(x/2)); % Input the function and interval
Df=diff(f,x);
T(x)=Df*(x)
disp('Tangent lines of f(x) at origin');
disp(T(x));
fplot(f(x));
legend(T(x),'tangent');
grid on;
hold on;
xlabel('x'); ylabel('y');
title('Graph of the tangent line');
0 commentaires
Réponses (1)
Ameer Hamza
le 30 Nov 2020
Modifié(e) : Ameer Hamza
le 30 Nov 2020
Compare following code with your code to see the mistakes
syms x y
f(x)=-(sin(x/2)); % Input the function and interval
Df=diff(f,x);
T(x)=subs(Df,x,0)*x;
disp('Tangent lines of f(x) at origin');
disp(T(x));
fplot(f(x));
hold on
fplot(T(x))
legend({'curve', 'tangent'});
grid on;
xlabel('x'); ylabel('y');
title('Graph of the tangent line');

1 commentaire
Shreesh Sahai
le 16 Juil 2021
Can I write a similar code if there's not a function, but a graph is obtained from observed data points?
Or, is there a way to find the function of a graph which has random data points?
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!