[Scilab-users] Peaks and valleys [was: Forum dedicated to Scilab developments -> practical concern]

Dang Ngoc Chan, Christophe Christophe.Dang at sidel.com
Fri Oct 7 10:50:18 CEST 2016


Hello,

> De : paul.carrico at free.fr
> Envoyé : jeudi 6 octobre 2016 12:32
>
> thanks for the information and the link

I updated the source code on the following page
https://commons.wikimedia.org/wiki/File:Savitzky-golay_pic_gaussien_bruite.svg
(vectorised, faster).

Concerning the use of the Savitzky-Golay algorithm itself,
once the algorithm is applied, something like
band = (sign(Ysecond (1:$-1)).*sign(Ysecond (2:$))==1)
will give you where the second derivative sign changes,
i.e. the bands where a peak or a valley lie,
and find(band) will give you the indices.

Then, you can search the min or the max in each band (on the smoothed data)
which should give you the position of the peaks and valeys.

I suggest to test several width of the window for each set of data
(the degree of the polynomial should always be 3 IMHO)
too let your brain finally decide what is a peak/valley and what is not.

HTH

--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


More information about the users mailing list