help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## Re: Weighted Moving Average

 From: James Sherman Jr. Subject: Re: Weighted Moving Average Date: Fri, 10 Aug 2007 09:01:47 -0400

Its not an octave thing, but a signal processing thing.  An FIR (finite input response) filter is determined by the vector of the coefficients, so if the filter has length 4, the output would be something like:
y(t) = b(1)*x(t) + b(2)*x(t-1) + b(3)*x(t-2) + b(4)*x(t-3)

So when b = ones(1,4)/4;, it is just the average of the last four elements.

In octave, you can use the function "filter" to do exactly that, if x is your signal, you can simply do
y = filter(b, 1, x);

James

P.S. This is almost the same as Søren's suggestion to use convolution (using the conv function).  The only difference (I believe) is that filter will give the same output as conv, but truncated to the length of x.

On 8/10/07, Luca Delucchi <address@hidden> wrote:
2007/8/10, Schirmacher, Rolf <address@hidden>:
> Filter with an FIR filter? Coefficients would be
>
> b = [1 1 1 1] ./ 4
>

What is this? Sorry but I'm a newbie of octave

> HTH,
>
> Rolf
>

Luca

> > -----Original Message-----
> > From: Luca Delucchi [mailto: address@hidden]
> > Sent: Friday, August 10, 2007 9:20 AM
> > To: octave
> > Subject: Weighted Moving Average
> >
> >
> > Hi, I can do a function on Weighted Moving Average where the value are
> > take in automatic mode? this my idea
> >
> > #y=[y1,y2,y3,y4,y5]
> > function wma(y)
> > (y1+2*y2+y3)/4
> > (y2+2*y3+y4)/4
> > etc
> > etc
> > end function
> >
> > I could not repeat the formula (y1+2*y2+y3)/4 (because if the long of
> > vector is different i must change the function) but have only one
> > formula that use the formula for all values of vector
> >
> > I hope I've given a clear explanation
> >
> > Luca
> > _______________________________________________
> > Help-octave mailing list
> > address@hidden
> > https://www.cae.wisc.edu/mailman/listinfo/help-octave
> >
>
_______________________________________________
Help-octave mailing list
address@hidden
https://www.cae.wisc.edu/mailman/listinfo/help-octave

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]