hot to calculate peaks of an "irregular" sine wave

  • Thread starter Thread starter federico tiso
  • Start date Start date
F

federico tiso

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
 
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
 
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!

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
 
Back
Top