Need help on a SPECIFIC CASE of finding local extreme
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!