I have many different data sets which are discrete data. The local minimum is not necessary the smallest data but it is the valley around the first peak. I am trying to find the indices of the first valley around the the first peak. My idea is to search the difference between two neighbor points and when the difference is less than some critical value and when the forward point larger than the backward point, then that’s the point we wanted. e.g.
for k=PEAK_POS:END_POS
if ( (abs(y(k)-y(k-1))<=0.01) && (y(k-1)>y(k)) )
expected_pos = k;
break;
end
end
this works for some data set but not for all since some dataset might have different sample step so we might change the critical condition but I have so many data set to analyse, I don’t think I can analyze each set manually. I am looking for any better way to find that minimum. Thanks.
As mentioned by @JakobS., optimization theory is a large field in Mathematics, with its own journals and conferences and everything.
Your problem does not sound complicated enough to justify the optimization toolbox (correct me if I’m wrong). It sounds like
fminsearchis sufficient for your needs. Here’s a brief tutorial for it. Typehelp fminsearchordoc fminsearchfor more info.The result is
Which is obviously a very reasonable approximation to the expected local optimum.