Results 1 to 6 of 6

Thread: discrete signal average

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    4

    discrete signal average

    Hi all,

    How can I find the average of a discrete signal in matlab, I know all the values of the signal ( i.e I know the y value for each x value ). In continuous waveform we can use (1/T)*integration( f(t)*dt ) , but I don’t know what should I use for a discrete signal??

    pls not the signal is periodic

    Thanks,

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    I'd assume it would be something along the lines of summation(all the elements in the set)/(# of elements in set). Here's a thread briefly discussing it: http://www.vbforums.com/showthread.p...hreadid=285583
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  3. #3
    Junior Member
    Join Date
    Jan 2003
    Location
    53776564656E
    Posts
    24

    Just be careful

    As you mention, for a continuous wave the average of a periodic signal is the integral over a period divided by the period length. This means, that in order to find the average of your discrete function, you should perform an numerical integration, using for instance the trapezoidal formula (aka the midpoint formula).

    This means that for all pairs of neighbouring points you form a trapezoidal element and calculate its area, simply by calculating the height at the midpoint (that is, the average y-value of the two neighbours) and multiply by the step length (difference in x-value). Then you find an approximate value of the integral by summing all these areas. Just make sure that you do not miss out one element in the end, common mistake!! Finally, you get the average by dividing by the period length.

    IMPORTANT NOTE:
    If your discrete points are evenly distributed (that is, the same difference in x between all points) - which is not unusual at all - these calculations are simplified a lot. In that case, you find the average of the function just by calculating the average value of the points. You do this by summing the y-values of all the points and dividing by the number of points, just as mentioned by jemidiah in the previous post.

  4. #4

    Thread Starter
    New Member
    Join Date
    Mar 2004
    Posts
    4
    Dear jskog,

    Thanks a lot for your great solutions but I feel there is a little contradiction between the two solution that we need to discuss.

    before continuing any more lest assume that we want to calculate the average of a discrete sinusoidal signal ( t form 0 ~ pi ).

    In the first solution you suggest calculating the area, by calculating the height at the midpoint and multiply it by the step length (difference in x-value), them sum all these areas and divide it by the period length.

    Applying this to our signal the average will be a positive value > 0 since there is no negative area.

    Now moving to the second solution (yes, my data are evenly distributed) you suggest finding the signal average by summing the y-values of all the points and dividing by the number of points.

    Applying this again to our signal, the average will be 0, because the symmetry of sinusoidal function (0~pi/2 => positive values) , ( pi/2~pi => negative values ).

    Don’t’ you find the above little bit strange???

    Hope to hear your comment soon.

    Best wishes,
    wildmatrixII

  5. #5
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431
    When you get into calculus, you'll work a lot with this type of stuff. For what you want, it probably should be zero, though you could always absolute-value it (what you do when you want total distance traveled instead of displacement). It's really dependant on what you need.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  6. #6
    Junior Member
    Join Date
    Jan 2003
    Location
    53776564656E
    Posts
    24
    Sorry for my late reply, I was away from the forums for a few weeks. (was deep into c++ coding)
    Originally posted by wildmatrixII
    Applying this to our signal the average will be a positive value > 0 since there is no negative area.
    Now you really got a point here. There is for sure no negative area. That's why what I wrote was a quite clumpsy way to describe what I meant. Of course, to be able to use this model, you must allow the "area" to be negative. Since you are supposed to multiply the average y by the delta x, the sign of your "area" element will depend on the sign of the current y value. Hope this cleared things out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width