hot to calculate peaks of an "irregular" sine wave

Discussion in 'Microsoft Excel Programming' started by federico tiso, Nov 9, 2011.

  1. 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
     
    federico tiso, Nov 9, 2011
    #1
    1. Advertisements

  2. federico tiso

    Andrew Guest

    On Nov 9, 5:22 am, federico tiso <> 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, Nov 10, 2011
    #2
    1. Advertisements

  3. federico tiso

    Andrew Guest

    On Nov 10, 6:15 am, Andrew <> wrote:
    > On Nov 9, 5:22 am, federico tiso <> 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
     
    Andrew, Nov 11, 2011
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave

    Irregular VBA error with data validation

    Dave, Oct 20, 2003, in forum: Microsoft Excel Programming
    Replies:
    2
    Views:
    300
  2. Marian

    Irregular areas of numbers

    Marian, Nov 6, 2003, in forum: Microsoft Excel Programming
    Replies:
    3
    Views:
    195
    Marian
    Nov 13, 2003
  3. Oliver Kharraz

    RefEdit irregular behavior - corrective measures wanted

    Oliver Kharraz, Dec 2, 2003, in forum: Microsoft Excel Programming
    Replies:
    1
    Views:
    341
    Jon Peltier
    Dec 2, 2003
  4. LB

    period of sum of sine waves

    LB, Aug 12, 2004, in forum: Microsoft Excel Programming
    Replies:
    3
    Views:
    3,396
  5. Finding major peaks and troughs

    , Feb 22, 2006, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    260
Loading...

Share This Page