Refining set of local maxima and minima based on alternating criteria
2 次查看(过去 30 天)
显示 更早的评论
Dear all,
I have a time series "vY" with dimension (t,1).
I have identified the points in the time series that represent local maxima and minima based on a rolling window criterion.
I then created two matrices:
"mMax" which has dimension (t,2). The first column are time periods. The second column is the value of "vY" associated with that time period. "mMax" contains all the local maxima. For instance, if a row of "mMax" is (3,0.05), that means that in period 3, when "vY" equals 0.05, one is at a local maxima.
"mMin" is defined in the same manner for minima.
I now want to select only those local maxima and minima such that each local maximum is followed by a local minimum and each local minimum is followed by a local maximum.
It so happens that my time series "vY" has some subsets of it in which that are contiguous local maxima or local minima (for instance, there is a local maximum at t=8, another at t= 11 and another at t=14 with no local minimum between t=8 and t = 14 and the next local extremum is a minimum at t=23 and the previous local extremum is a minimum at t=3). In this case, I would like to choose the local maximum of the three contiguous maxima (t=8, t=11,t=14) which is largest.
In general, I want to select, for each subset of at least 2 contiguous local maxima, the local maximum that is largest. Moreover, if there is a case in which there are (at least) two local maxima, in a given subset of contiguous maxima of "y", that take the same value such that value is the largest in that subset, I which to keep the one that occurs later in time. Analogously, I which to keep as local minimum, for each subset of at least 2 contiguous local minima, the local minimum that is smallest. If there is a case in which there are (at least) two local minima, in a given subset of "y", that take the same value such that that value is the smallest in that subset, I which to keep the one that occurs latter in time.
My question is basically: how can I do this? I've been trying this for quite a while (several days!) with no success...
Thanks for your help, If something was not clear let me know
James
2 个评论
Image Analyst
2016-7-1
Make it easy for us to help you by supplying some arrays (input and output). If you wait until someone goes to the trouble of making those sample arrays themselves, then you may be waiting a very long time, if anyone even answers.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!