# hot to calculate peaks of an "irregular" sine wave

federico tiso
Guest
Posts: n/a

 9th Nov 2011
Hello everybody,
I need to calculate the distance between each peaks of an irregular
sinusoidal wave, similar to this one http://imageshack.us/photo/my-images/528/grapha.jpg
, where each peak is represented by a red dot.

I am a very beginner with excel so I am already sorry for my
questions.
I have the graphs (and I also would like to show on the graph each
peak, as in the picture above I simply put a big red dot with Paint)
and all the values of the curve, obviously. I am looking for a
function/algorythm to calculate these peaks and their distance, as I
need to do a similar task with several graphs.

These datas are taken from a gyroscope, a device to measure (also)
changes in angles; for its intrinsic characteristics, it tends to
drift (without a linear pattern, even it may seem linear).

Any helps would be more than appreciated!

Federico

Andrew
Guest
Posts: n/a

 10th Nov 2011
On Nov 9, 5:22*am, federico tiso <(E-Mail Removed)> wrote:
> Hello everybody,
> I need to calculate the distance between each peaks of an irregular
> sinusoidal wave, similar to this onehttp://imageshack.us/photo/my-images/528/grapha.jpg
> , where each peak is represented by a red dot.
>
> I am a very beginner with excel so I am already sorry for my
> questions.
> I have the graphs (and I also would like to show on the graph each
> peak, as in the picture above I simply put a big red dot with Paint)
> and all the values of the curve, obviously. I am looking for a
> function/algorythm to calculate these peaks and their distance, as I
> need to do a similar task with several graphs.
>
> These datas are taken from a gyroscope, a device to measure (also)
> changes in angles; for its intrinsic characteristics, it tends to
> drift (without a linear pattern, even it may seem linear).
>
> Any helps would be more than appreciated!
>
> Federico

Good question... If I were doing this, I would take the differential
of the wave. If you had an actual function of the wave form and you
took the differential of it, the differential value would be equal to
zero at each peak, both positive and negative.

So, let's say the wave is represented by an array 100 elements long.
The first differential would be [Y(2)-Y(1)]/time. You could do this
with a For loop. The example below is sort of crude, but it will get
you in the ball park.

Y=sine values
T = time values
tol = tolerance value
tol=.1
peak_n = counter value

For i = 2 to 100
dS=(Y(i)-Y(i-1) )/(time(i)-time(i-1))
if dS<tol, then peak = time(i)
peak_n=peak_n+1
worksheets(1).cells(peak_n,1)
end if
next

Andrew
Guest
Posts: n/a

 11th Nov 2011
On Nov 10, 6:15*am, Andrew <(E-Mail Removed)> wrote:
> On Nov 9, 5:22*am, federico tiso <(E-Mail Removed)> wrote:
>
>
>
> > Hello everybody,
> > I need to calculate the distance between each peaks of an irregular
> > sinusoidal wave, similar to this onehttp://imageshack.us/photo/my-images/528/grapha.jpg
> > , where each peak is represented by a red dot.

>
> > I am a very beginner with excel so I am already sorry for my
> > questions.
> > I have the graphs (and I also would like to show on the graph each
> > peak, as in the picture above I simply put a big red dot with Paint)
> > and all the values of the curve, obviously. I am looking for a
> > function/algorythm to calculate these peaks and their distance, as I
> > need to do a similar task with several graphs.

>
> > These datas are taken from a gyroscope, a device to measure (also)
> > changes in angles; for its intrinsic characteristics, it tends to
> > drift (without a linear pattern, even it may seem linear).

>
> > Any helps would be more than appreciated!

>
> > Federico

>
> Good question... If I were doing this, I would take the differential
> of the wave. *If you had an actual function of the wave form and you
> took the differential of it, the differential value would be equal to
> zero at each peak, both positive and negative.
>
> So, let's say the wave is represented by an array 100 elements long.
> The first differential would be [Y(2)-Y(1)]/time. *You could do this
> with a For loop. *The example below is sort of crude, but it will get
> you in the ball park.
>
> Y=sine values
> T = time values
> tol = tolerance value
> tol=.1
> peak_n = counter value
>
> For i = 2 to 100
> dS=(Y(i)-Y(i-1) *)/(time(i)-time(i-1))
> if dS<tol, then peak = time(i)
> peak_n=peak_n+1
> worksheets(1).cells(peak_n,1)
> end if
> next

I made a mistake on my example from yesterday.

For i = 2 to 100
dS=(Y(i)-Y(i-1) )/(time(i)-time(i-1)) ' This calculates the
differential at each point, starting at item 2
if abs(dS)<tol, then peak = time(i) ' See if the differential
is less than the tolerance value. If true record time of peak (or x
axis value)
peak_n=peak_n+1 ' If it is, then
increment the number of peaks found
worksheets(1).cells(peak_n,1)=peak ' Put the time value onto a
worksheet
end if
next

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post ben Microsoft Excel Charting 5 15th Oct 2012 09:00 AM federico tiso Microsoft Excel Worksheet Functions 1 16th Nov 2011 08:56 AM Amedee Van Gasse Microsoft Excel Misc 10 12th Jul 2005 04:01 PM dumb_founded Microsoft Excel Discussion 3 11th Apr 2005 12:26 PM =?Utf-8?B?QnJpYW4=?= Microsoft Excel Misc 2 11th Sep 2004 09:50 PM

Features