Finding peaks in data based on certain threshold

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

 Respuesta aceptada

Shoaibur Rahman
Shoaibur Rahman el 20 de Dic. de 2014
Editada: Shoaibur Rahman el 20 de Dic. de 2014

2 votos

Once I had to write a function for this type of problem in on of my projects. Seeing your question here, I have uploaded that file in file exchange:
Just use your +/-TestV as x, Data as y in the function, and threshold as 0.1. Ignore the outputs for minima.
By the way, if you have a closer look at your figure, there are two small peaks in 'left side', one big peak in 'middle', and one smaller peak at the 'right'. So, there will be 4 peaks in total instead of 3. Plot this data in Matlab, and enlarge the figure to verify this observation.
I guess, if you use the linked function findpeaks, the result will be 4 as well. You could also see the x coordinate at which peaks occur, and also the peak values at those points.

Más respuestas (1)

Image Analyst
Image Analyst el 20 de Dic. de 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 comentarios

Satej
Satej el 20 de Dic. de 2014
Editada: Image Analyst el 20 de Dic. de 2014
Thanks for your response. Please excuse me for not being very clear. Here is an example
X = [4 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8];
Y = [3 5 25 18 10 7 6 12 4];
threshold = 10
% Need to find Y values = [5 10 6 4]
% Corresponding X indexes are = [4.1 4.4 4.6 4.8]
These are values that are either starting points before crossing threshold or points equal to threshold or first points after crossing threshold
Thanks in advance for your help and input Best SATEJ
Image Analyst
Image Analyst el 20 de Dic. de 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
Star Strider el 20 de Dic. de 2014
Thanks, I A.
To provide a context, I deleted my Answer because it was neither Accepted nor Voted.
Image Analyst
Image Analyst el 20 de Dic. de 2014
Why bother to do that? It had good and clever code in it that may help someone else someday.
Satej
Satej el 22 de Dic. de 2014
Hi SS - Can you please post your code to the problem above. I thought I had accepted that answer. That code is very useful. Can you please repost it??? My sincere thanks for same
Best Satej
Joshua Briggs
Joshua Briggs el 28 de Mzo. de 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.

Iniciar sesión para comentar.

Preguntada:

el 20 de Dic. de 2014

Comentada:

el 28 de Mzo. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by