Technical discussion about Matlab and issues related to Digital Signal Processing.
|
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 > _____________________________________ > /groups.php3 |
|
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 |