rom: Olivier Crouzet <address@hidden>
To: asha g <address@hidden>
Sent: Thursday, 29 March 2012 2:43 PM
Subject: Re: findpeak -> peakdet.m ?
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.
Will try this and get back. I prefer a ready made code if it works.
BTW, do you top post or bottom post if you are asking a question ? I am confused.
Asha
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/