Path: news.mathworks.com!newsfeed-00.mathworks.com!newscon02.news.prodigy.net!prodigy.net!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!19g2000hsx.googlegroups.com!not-for-mail
From:  Randy Poe <poespam-trap@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Moving averages over a vector in MatLAB?
Date: Thu, 01 Nov 2007 11:34:01 -0700
Organization: http://groups.google.com
Lines: 64
Message-ID: <1193942041.234629.236300@19g2000hsx.googlegroups.com>
References: <fgcuei$32r$1@fred.mathworks.com>
NNTP-Posting-Host: 192.35.37.20
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
X-Trace: posting.google.com 1193942041 31486 127.0.0.1 (1 Nov 2007 18:34:01 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 1 Nov 2007 18:34:01 +0000 (UTC)
In-Reply-To: <fgd1jg$lv3$1@fred.mathworks.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4,gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 squid.atl.lmco.com:3128 (squid/2.5.STABLE14)
Complaints-To: groups-abuse@google.com
Injection-Info: 19g2000hsx.googlegroups.com; posting-host=192.35.37.20;
Bytes: 3849
Xref: news.mathworks.com comp.soft-sys.matlab:435693



On Nov 1, 1:15 pm, "Dave Robinson" <dave.robin...@somewhere.biz>
wrote:
>  Randy Poe <poespam-t...@yahoo.com> wrote in message
> <1193935442.969959.94...@50g2000hsm.googlegroups.com>...
>
> > On Nov 1, 12:21 pm, "Erik Carlsten" <ecarl...@yahoo.com>
> wrote:
> > > Hi everyone, recently I have been doing some analysis on
> > > some FFTS trying to find and analyze regions with peaks.
> > > One thing we have been doing to make this process easier
> > > is to take a moving average of the FFT before analyzing
> > > the peaks to ensure that rogue spikes in our FFTs do not
> > > mislead our signal processing. However, one problem I am
> > > forseeing is just how slow our current moving average
> is.
> > > Currently we are simply looking at x points on the left
> > > side and x points on the right side of our current point
> > > and taking a mean of that data and then setting the same
> > > index in our new smoothed out FFT vector to be that mean
> > > value. I would like to see if anyone knows a slick way
> to
> > > accomplish this with either a built in toolbox function
> or
> > > if there is a way to apply a custom written function to
> > > each index in a vector without a for loop.
>
> > > Below is some code that is similar to what we are
> > > currently using to accomplish our FFT smoothing process.
> > > FFTVect represents our intensity values at a given
> > > frequency. We are simply trying to build a new "smoothed
> > > out" FFT that does not show any thin but tall spikes
> that
> > > our original FFT shows. This averaging process
> eliminates
> > > this issue previous to our peak analysis but the way we
> > > are currently doing it seems very slow and clunky. Any
> > > suggestions?
>
> > > avgWin = 10;
>
> > > avgFFT = FFTvect;
>
> > > for index = avgWin+1:length(avgFFT)-avgWin
> > >     avgFFT(index) = mean(FFTVect(index-
> > > avgWin:index+avgWin));
> > > end
>
> > This is a convolution with the rectangular
> > window function [1/N 1/N .... 1/N]. Look up
> > CONV or FILTER.
>
> Just a thought here, if you are convolving with a
> rectangular window in the frequency domain, isn't that
> simply a multiplication with a sync function in the time
> domain, which must be a lot faster.

I believe that CONV and FILTER both use that approach,
but do all the index bookkeeping for you. That's why
I suggested them. I may be wrong on CONV however,
because it does append those extra elements at the
beginning and end.

                    - Randy