[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: findpeak
From: |
Luke M |
Subject: |
Re: findpeak |
Date: |
Wed, 28 Mar 2012 10:37:59 -0700 (PDT) |
asha g wrote
>
> Sorry, I can't get this to work but is there something in octave similar
> to Matlab's
> pks = findpeaks(data)
> [pks,locs]
> = findpeaks(data) returns the
> indices of the local peaks.
>
> If I can get this, then my problem is solved.
> Thanks
> Asha
>
One simple solution (O(n), in algorithm design terms):
- place the first element in a "candidate vector"
- loop through each element 2 through end, comparing it to the previous one
---if it's higher, set the candidate vector to the current element
---if it's equal, append the current element to the candidate vector
---if it's lower,
-----if the candidate vector is not empty, save the local maxima and idx
from the candidate vector and empty the candidate vector
Problems you would have to solve:
- Which index do you want to save in the case of a flat peak (length of
candidate vector > 1)?
- How do you want to handle possible local maxima at the beginning and end
(e.g. [2 1 2 3 2 1 2]? The algorithm above will find a local maximum in the
first element, but not in the last element. Whether you want to ignore both
or save both is an easy fix.
--
View this message in context:
http://octave.1599824.n4.nabble.com/Re-Reading-mat-file-tp4487833p4513068.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Re: Reading mat file, (continued)
- Re: Reading mat file, asha g, 2012/03/21
- Re: Reading mat file, ahowe42, 2012/03/21
- Re: Reading mat file, asha g, 2012/03/21
- Re: Reading mat file, asha g, 2012/03/21
- Message not available
- Re: Reading mat file, asha g, 2012/03/21
- Re: Reading mat file, Doug Stewart, 2012/03/21
- Re: Reading mat file, ahowe42, 2012/03/21
- Re: Reading mat file, Jordi GutiƩrrez Hermoso, 2012/03/21
- findpeak, asha g, 2012/03/28
- findpeak, asha g, 2012/03/28
- Re: findpeak,
Luke M <=
- Re: findpeak, asha g, 2012/03/29
- Re: findpeak, Luke M, 2012/03/29
- Re: findpeak -> peakdet.m ?, Olivier Crouzet, 2012/03/29
- Message not available
- Re: findpeak -> peakdet.m ?, Olivier Crouzet, 2012/03/30
- Re: findpeak -> peakdet.m ?, asha g, 2012/03/31
- Message not available
- Re: findpeak -> peakdet.m ?, asha g, 2012/03/29
- Re: Reading mat file, asha g, 2012/03/21
- Re: Reading mat file, Mech.Mon, 2012/03/22
- Re: Reading mat file, Luke M, 2012/03/29
- Re: Reading mat file, asha g, 2012/03/30