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.

10 visualizzazioni (ultimi 30 giorni)
(For reference of the first photo)
  5 Commenti
Torsten
Torsten il 3 Ott 2022
Modificato: Torsten il 3 Ott 2022
syms x
%IDENTIFY the function f(x)
f = x^3-3*x+2
f = 
%DETERMINE the point of tangency (This will be a random point)
x0=randi([-5,5])
x0 = 0
%SOLVE for the Ordinate of the point of tangency
y0=subs(f,x0) %Evaluate y given value fo x
y0 = 
2
%FIND the slope function
yprime =diff(f,x) %Solve for the first derivative
yprime = 
%Determine the slope at the given x0
m=subs(yprime,x,x0) %Evaluate the slope
m = 
%Solve the equation of the tangent line
ytangent= m*(x-x0)+y0
ytangent = 
%Solve the Equation of the normal line
ynormal= (-1/m)*(x-x0)+y0
ynormal = 
%DISPLAYING RESULTS
fprintf('The tangent line to f(x)=%s at (%.2f, %.2f) is y = %s \n',string(f),x0,y0, string(ytangent))
The tangent line to f(x)=x^3 - 3*x + 2 at (0.00, 2.00) is y = 2 - 3*x
fprintf('The normal line to f(x)=%s at (%.2f, %.2f) is y = %s \n',string(f),x0,y0, string(ynormal))
The normal line to f(x)=x^3 - 3*x + 2 at (0.00, 2.00) is y = x/3 + 2

Accedi per commentare.

Risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by