Azzera filtri
Azzera filtri

Need help on a SPECIFIC CASE of finding local extreme

1 visualizzazione (ultimi 30 giorni)
I wrote a code to find local extremes and tested it with a few functions. Things were going smoothly until this ONE CASE: f(x)=(x+1)^(2/3)-x. Matlab returns only one local extreme where there should have been two. I also included the ezplot function in my code to see how the graphs look but when Matlab sketch this function's graph it.....just CAN'T, it only graphs the funtion from -1 while the domain of the function itself is much larger.
Note: My code runs with other functions like discontinuos function: abs(x) and ofcourse smoothly with continous functions.
disp('This is MaxImin');
syms x ;
disp(' please input f');
f = input('f(x)=');
g = diff(f);
h = diff(g)
CP = solve(diff(f),x)
s = numel(CP)
for i=1:s
if subs(h,CP(i))>0
disp('Local minima is achieved')
Min=[CP(i);subs(f,CP(i))]
elseif subs(h,CP(i))<0
disp('Local Maxima is achieved')
Max=[CP(i);subs(f,CP(i))]
end
end
ezplot(f);
hold on;
plot(CP,subs(f,CP(i)),'r o');
grid on;

Risposte (0)

Categorie

Scopri di più su Discrete Data Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by