how to find two minimums within a range?

6 visualizaciones (últimos 30 días)
Subash Niraula
Subash Niraula el 26 de En. de 2021
Respondida: Bladi Toaza el 27 de En. de 2021
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.

Respuestas (1)

Bladi Toaza
Bladi Toaza el 27 de En. de 2021
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).

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by