How can I limit the argument in coding the roots of a fraction?
2 ビュー (過去 30 日間)
古いコメントを表示
The error is shown that "Error using roots. Too many input arguments."
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1143780/image.png)
because the derivative of the function is a fractional equation
(Ps. I already changed the roots(fp,x,1) as shown below)
here is the code for it
%Use symbolic processing with the variable x
syms x
%Enconde the function f(x)
f(x) = (1+x^2)/(1-x^2);
%Set the distance to the left/right of the critical point
h=0.01
%Find the first derivative of the function
fp(x) = diff(f,x)
%Solve for the roots of fp
root1 = roots(fp,x)
%Consider the first critical point only
c=root1(1)
%Determine if the function is "Increasing" or "Decreasing" at the right of the critical point
if (fp(c+h)>0)
IoDR = "Increasing"
elseif (fp(c+h)<0)
IoDR = "Decreasing"
end
%Determine if the function is "Increasing" or "Decreasing" at the right of the critical point
if (fp(c-h)>0)
IoDL = "Increasing"
elseif (fp(c-h)<0)
IoDL = "Decreasing"
end
%Use first derivative Test to Determine if the critical point is a "Maximum" point or "Minimum" point.
if IoDL=="Increasing" & IoDR =="Decreasing"
CP= "Maximum"
elseif IoDL=="Decreasing" & IoDR =="Increasing"
CP= "Minimum"
end
%Find the second derivative of the function
fpp(x)= diff(f,2);
%Find the points of inflection of the function by equating the second derivative of the function to zero.
cc = diff(fp,x)
%Apply Second Derivative Test to check whether the critical point is a "Maximum" point, a "Minimum" point or "Point of Inflection".
if fpp(c) >0
CP2 = "Maximum"
elseif fpp(c)<0
CP2 = "Minimum"
else
CP2 = "Point of Inflection"
end
%GRAPH THE FUNCTION
clf();
g1= ezplot(f);
hold on
grid on
plot(c,f(c), 'r*')
title("Curve Tracing")
text(c+.5,f(c),["("+string(c)+","+string(f(c))+") "+CP ])
4 件のコメント
回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!