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.
2 次查看(过去 30 天)
显示 更早的评论
(For reference of the first photo)
5 个评论
Torsten
2022-10-3
编辑:Torsten
2022-10-3
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))
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!