DSPRelated.com
Forums

Running Average

Started by Unknown November 14, 2001
I am new to using Matlab and Simulink. I am trying to model a systems
that contains a running average. Does anyone know a way to model this?
The requirement is something like

output = a running average of latest 0.75 seconds of the input.

Any help is appreciated

Thank you




hi ???,

it sounds like a homework?
if you don't need some form of real time
any form of conv will do. if you are
interested in optimising this, you
may use the very,very famous :
"next outgoing sample" = "last outgoing sample"
+ "newest incoming sample" - "incoming sample 0.75 sec past"
you need a memory for the outgoing sample
and a cycl. buffer for the last incoming samples.
have a nice time.
BTW.: designing any signal processing algorithm
( running avarage is one of the simplest one )
you have to think twice about the border
(i.e. what to do at the begining and the ending
of our incoming samples)
again: have a nice time.

michael schrieb:
>
> I am new to using Matlab and Simulink. I am trying to model a systems
> that contains a running average. Does anyone know a way to model this?
> The requirement is something like
>
> output = a running average of latest 0.75 seconds of the input.
>
> Any help is appreciated
>
> Thank you > _____________________________________
> Note: If you do a simple "reply" with your email client, only the author of
this message will receive your answer. You need to do a "reply all" if you want
your answer to be distributed to the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join:
>
> To Post:
>
> To Leave:
>
> Archives: http://www.yahoogroups.com/group/matlab
>
> More DSP-Related Groups: http://www.dsprelated.com/groups.php3
>
> ">http://docs.yahoo.com/info/terms/




Hi,
Try this:

function[out] = runavg(in,N)
%N - window length
%in - input vector
%out - output vector

for(i=1:length(in)-N)
out(i)=sum(in(i:i+N)/N);
end

Michal