Can someone tell me how will I be able to remove the error in this script? I have already the answers but it says error.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
(For reference of the first photo)
5 commentaires
Torsten
le 3 Oct 2022
Modifié(e) : Torsten
le 3 Oct 2022
syms x
%IDENTIFY the function f(x)
f = x^3-3*x+2
%DETERMINE the point of tangency (This will be a random point)
x0=randi([-5,5])
%SOLVE for the Ordinate of the point of tangency
y0=subs(f,x0) %Evaluate y given value fo x
%FIND the slope function
yprime =diff(f,x) %Solve for the first derivative
%Determine the slope at the given x0
m=subs(yprime,x,x0) %Evaluate the slope
%Solve the equation of the tangent line
ytangent= m*(x-x0)+y0
%Solve the Equation of the normal line
ynormal= (-1/m)*(x-x0)+y0
%DISPLAYING RESULTS
fprintf('The tangent line to f(x)=%s at (%.2f, %.2f) is y = %s \n',string(f),x0,y0, string(ytangent))
fprintf('The normal line to f(x)=%s at (%.2f, %.2f) is y = %s \n',string(f),x0,y0, string(ynormal))
Réponses (0)
Voir également
Catégories
En savoir plus sur Calculus 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!