# How to compute the height of a peak relative to the previous amplitude before the peak?

10 Ansichten (letzte 30 Tage)
Med Aymane Ahajjam am 7 Jan. 2020
Kommentiert: Teo Bistoni am 7 Okt. 2020
Dear all,
I am trying to compute the height of a peak detected using findpeaks function. The peak height should be computed relative to the previous amplitude before the peak (left side), as opposed to the prominence of the peak that computes the minimum vertical distance that the signal must descend on either side of the peak before either climbing back to a level higher than the peak or reaching an endpoint.
example:
The left subplot is the result of the function findpeaks on the signal: The first peak prominence equals the wanted height, since it was computed realtive to the horizontal line (1). The second peak prominence does not equal the wanted height since it was computed realtive to the same horizontal line (1).
The right subplot is the result wanted: The second peak's height should be computed relative to the horizontal line (2).
##### 2 KommentareKeine anzeigenKeine ausblenden
Alex Mcaulley am 7 Jan. 2020
Bearbeitet: Alex Mcaulley am 7 Jan. 2020
Do you mean this?
findpeaks(diff([0,A]))
Med Aymane Ahajjam am 8 Jan. 2020
no actually..

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Sylvain Lacaze am 8 Jan. 2020
Hi Med,
Can you trust that you want the amplitude with respect to the sample point prior to the peak?
Something like:
[~, peakLocations] = findpeaks( a );
amplitude = arrayfun( @(location) a(location) - a(location-1), peakLocations );
HTH,
Sylvain
##### 2 KommentareKeine anzeigenKeine ausblenden
Med Aymane Ahajjam am 9 Jan. 2020
Hi there SIlvian,
thank you very much! it works!
Teo Bistoni am 7 Okt. 2020
Hi sylvain, what if i don't know if there is another sample point between the peak and the minimum?

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Descriptive Statistics finden Sie in Help Center und File Exchange

R2019a

### Community Treasure Hunt

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

Start Hunting!

Translated by