how to find two minimums within a range?
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello People,
I got stuck on question regarding finding 2 minima of function. the equation is
f(x)= exp(-sqrt(x))+ 0.1*sin(3x)
In question it says using function handles, does that mean i have to define function handle specifically, and call it later or i can use anonymous function. I have written following code using anonymous function but it won't return both values together.
>>fminbnd(@(x)exp(-sqrt(x))+0.1*sin(3*x),0,2) and
>>fminbnd(@(x)exp(-sqrt(x))+0.1*sin(3*x),2,5)
Any suggestions would help. As always,thank you for your trouble and Good health to you.
댓글 수: 0
답변 (1개)
Bladi Toaza
2021년 1월 27일
As I understand you are looking fot the local minima of the functions. You can use the function islocalmin. This will return a logical array with values 1 (true) when it is a lcoal minima.
f= exp(-sqrt(x))+ 0.1*sin(3x)
TF = islocalmin(f)
plot(x,f,x(TF),f(TF),'r*')
This will return the local mimima of the functions (that could be 1,2 or more).
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!