[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: findpeak -> peakdet.m ?
From: |
Olivier Crouzet |
Subject: |
Re: findpeak -> peakdet.m ? |
Date: |
Thu, 29 Mar 2012 11:15:31 +0200 |
Hi,
I Don't know if it's relevant (perhaps you really want to program it
yourself, perhaps you know it and it doesn't exactly fit your needs) but
Eli Billauer provides a script named peakdet.m
(http://billauer.co.il/peakdet.html) which does exactly that: locate
peaks (and valleys too) and returns 'y' and, either 'x' or the vector
indices. It also allows to specify a delta when one wants only global
peaks, not every local one (particularly usefull when there is noise
in the data). I often use it these times and it does a very good job
(and it's also available for python and C; I haven't tested these but
links are provided on the web page).
The bottom side is that it uses a "for" loop and may therefore take a
long time on huge data, but I suspect there's perhaps no other way when
one wants to parameterize a "delta" (I didn't take the time to try such
a modification)...
The script is written with matlab "style" but works as a charm within
octave.
Olivier.
On Wed,
28 Mar 2012 14:26:06 +0800 (SGT) asha g <address@hidden> wrote:
>
>
>
>
> Regardless, here's a solution that *won't work for every dataset*,
> but I think will work in your case.
>
> % first derivative (kind of)
> dx = diff(vvl);
> % second derivative (kind of)
> dxx = diff([0,dx]);
> % peaks (peaks = -2, troughs = 2)
> idx = find(dxx == -2);
>
> % now get the peak vvl values & corresponding x values
> vvl(idx)
> x(idx)
>
> I tested this with a very simple dataset and it worked, but can't
> guarantee it will always work. In particular, if the peak is
> something like this: [1,2,3,3,3,2,1], this code will not identify
> it. Looking at the plot you sent me, it should be ok.
>
> Andrew
>
> 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
--
Olivier Crouzet, PhD
Laboratoire de Linguistique -- EA3827
Département de Sciences du Langage
UFR Lettres et Langages
Université de Nantes
Chemin de la Censive du Tertre - BP 81227
44312 Nantes cedex 3
France
phone: (+33) 02 40 14 14 05 (lab.)
(+33) 02 40 14 14 36 (office)
fax: (+33) 02 40 14 13 27
e-mail: address@hidden
http://www.lling.fr/
- Re: Reading mat file, (continued)
- 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, 2012/03/28
- Re: findpeak, asha g, 2012/03/29
- Re: findpeak, Luke M, 2012/03/29
- Re: findpeak -> peakdet.m ?,
Olivier Crouzet <=
- 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
- Re: Reading mat file, Luke M, 2012/03/31
- Re: Reading mat file, Doug Stewart, 2012/03/21