Return curve peak coordinates - not just the peak

Hi,
I'm trying to get the whole curve where a peak belongs to, such as what I have badly drawn on the image using red colour. Is there a way to perform this please?
Thanks

 Akzeptierte Antwort

Star Strider
Star Strider am 26 Mai 2017

0 Stimmen

I would do something like this:
x = [1:17]*10; % Create Data
y = [0 1 0 2 0 9 0 3 0 1 0 2 0 9 0 3 0]*0.25; % Create Data
[pks1,locs1] = findpeaks(y, x, 'MinPeakHeight',2);
[pks2,locs2] = findpeaks(-y, x);
pk1_start = locs2(find(locs2 < locs1(1), 1, 'last')); % Start Of First Peak
pk1_end = locs2(find(locs2 > locs1(1), 1, 'first')); % End Of First Peak
... then do the same for the second peak, ‘locs1(2)’. With the start- and end-points, you can define the entire peak.
This makes some assumptions about your data, since I do not have them to work with. You will probably have to experiment with this idea for it to work with your data.

2 Kommentare

Giorgis
Giorgis am 5 Jun. 2017
Apologies for the late response, it wasn't possible to reply earlier. This will work great in finding the peak and the approximation of the curve. Thanks a lot!
No worries! The longest time between my posting an Answer and the person replying to (and Accepting) it was 198 days.
My pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by