Set of functions to look for local minima or maxima in a vector, find a point inside a vector closest to a certain value and small function to clear everything.
Sergei Koptenko (2021). Local min, max, nearest neighbour (https://www.mathworks.com/matlabcentral/fileexchange/3170-local-min-max-nearest-neighbour), MATLAB Central File Exchange. Retrieved .
Well done! This definitely saved me a lot of time!
Thank you so much.
Nice ans usefull
Nice work. It save a lot of my time.
1) Would like to see you add a threshold value so that it only find min and max that are below or above the threshold. I made a simple modification to the lmax and lmin to include that
2) Would also like to see adding the filtered curve to plot with the graph. I see the same problem with Claudio P. that in a high noise situation, the maxima are different for low and values of filt. Adding the smoothed curve will help me to determine which filt value to use
Usefull program saved my time. Thanx
Great, simple program. Works well, good examples. This program will save you time since there is no need for you to write what Koptenko has already done well.
Nice! Works quite well.
Excellent!! It rocks.
A couple of comments:
1) help for lmin is wrong, should be [b,a]=lmin... rather than [a,b]=lmin...
2) lmax is not finding the exact max with high 'filt' values, I had to increase the rng value at lmax.m line 55 in oder to have it wokring fine (maybe rng should not have a fixed value but should be proportional to filt?)
apart from that, everything ok ;)
I used the "match" function. Exactly what I was looking for, and works very well.
This is very helpfull! Thx! A LOT!
Interesting. How can this help me tackle my problem, here: http://www.mathworks.fr/matlabcentral/newsreader/view_thread/165101
Comments and help appreciated.
I love you! This has made my life so much easier
Very good! thanks for sharing us~!
i find extreme.m more simple to use
Works great...a real time saver.
Another user commented a while back that he is using it for "spike" detection. I am doing the same. If you want to find the spikes only, and not all local minima, first use "find" command to locate all points that have amplitudes above a certain criteria--all points with amplitude 5 sigma above the rms value of the signal, for instance
The life became easier now.
Steven Kay (firstname.lastname@example.org) is a fictional character:
....If you do so, please include this problem report. You can delete your own text from the message returned below.
The Postfix program
<email@example.com>: host cast.navnet.net[22.214.171.124] said: 550
<firstname.lastname@example.org>: User unknown in local recipient table (in reply to
RCPT TO command)....
nice work and very helpful
Thank you! You make the life easier!
Thanks a lot! You save my time :)
Incredibly useful!!! lmax identifies some local minima points if the number of passes are low.
[a,b]=localmax([0 2 0 0 0 0]) also has to tuned by hand. Nie code, but some rough spots. Could be improved.
great. works like a charm
it's very good
returns empty matrices for
[a,b]=localmax([0 0 0 0 2 0])
in max/min search loop, change
--> while i < len_x-1
-->while i < len_x
Other than that, does exactly as described.
1) another example? I?m sorry Bing, but if you just try to implement measures I mentioned in the first message you will see that function indeed gives the correct answer to the first example.
2) Concerning your example, the correctness of the answer lay not in the function?s output but in your original assumptions. The problem here is how to define the local maxima for a long flat spot. For instance, in [0 0 1 1 0 0] position of maximum can be defined at 3rd OR at the 4th position, at your liberty. In vector [0 0 1 1 2 2 1], 0011 can be defined as one-sided local maximum (a ledge) or as an absence of the maximum, depending on your views and needs. This is why I chose to adhere to the strict maxima criteria excluding flat spots altogether, but giving the possibility of including them if such a need arises through commented lines in the code.
Here is another example that it did not report correct answer.
If the input has two flat steps:
a=[0 1 1 2 2 0]
The middle step will be considered a local maxima...
indd =[2 4]
Not quite a bug but a feature :-)
If you go into the function body there are four lines commented out NN 41, 42, 45 and 46 that define if flat spots should be included in results. If you un-comment them, function will give a correct answer.
I guess there is a bug when the "peak" is flat, such as a=[3 4 5 5 4 3]. lmax returns empty.
I'm using this to find minima in a plot which involves a lot of sharp downward spikes; the goal is to find at what points these spikes land. It's a great program, but a future improvement may be to add in code that will register a minima if it attains a certain percent difference from a group of points previous to it. This seems sort of eccentric, but it may help in applied mathematical applications
Appology to all who loaded this file!
1) one bug was found and fixed in lmax_pw.m and lmin_pw.m
2) match.m wasn't stable dealing when first and last points were in the range- Fixed
Please reload zipfile in two-three days (new name should be "local_ext_mod.zip")
Inspired: Plot cylinder
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!