필터 지우기
필터 지우기

Need help on a SPECIFIC CASE of finding local extreme

조회 수: 1 (최근 30일)
Jacked Daniel
Jacked Daniel 2019년 12월 6일
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;

답변 (0개)

카테고리

Help CenterFile Exchange에서 Discrete Data Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by