Finding peaks in data based on certain threshold
Show older comments
Hi I have an array [V Data] (Attached data file).The plot is shown below.

I want to detect the # of peaks (3 in this case) which are above a certain threshold (value is = 0.1) I also want to find the points where it crosses the threshold and extract respective values from V
Thanks SATEJ
Accepted Answer
More Answers (1)
Image Analyst
on 20 Dec 2014
Describe what "detect" means to you. Obviously you threshold:
abovePointOne = v > 0.1;
but then what? What kind of numbers do you want? The length of the stretches above 0.1? The starting points? The count of the number of stretches above 0.1? What????
6 Comments
Satej
on 20 Dec 2014
Edited: Image Analyst
on 20 Dec 2014
Image Analyst
on 20 Dec 2014
It looks like Star's code gives you that plus even better in that it gives you sub-element resolution. If you need it on the exactly elements you said, then you'll have to do a more specialized, complicated routine. Probably a for loop where you're detecting if you're above the threshold and "in" the peak (in which case you'll keep the last index before you went above the threshold), or below the threshold but just went below it on this index (in which case you'll take that index instead of the prior one.)
Star Strider
on 20 Dec 2014
Thanks, I A.
To provide a context, I deleted my Answer because it was neither Accepted nor Voted.
Image Analyst
on 20 Dec 2014
Why bother to do that? It had good and clever code in it that may help someone else someday.
Satej
on 22 Dec 2014
Joshua Briggs
on 28 Mar 2017
Hi I am looking to do something similar to Satej, and IA's description of SS's code sounds like exactly what I need, just wondering if anyone has it, or if SS could please repost it.
Categories
Find more on Parametric Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!