Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!50g2000hsm.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 09:44:02 -0700
Organization: http://groups.google.com
Lines: 42
Message-ID: <1193935442.969959.94480@50g2000hsm.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 1193935443 16219 127.0.0.1 (1 Nov 2007 16:44:03 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 1 Nov 2007 16:44:03 +0000 (UTC)
In-Reply-To: <fgcuei$32r$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: 50g2000hsm.googlegroups.com; posting-host=192.35.37.20;
Xref: news.mathworks.com comp.soft-sys.matlab:435680



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.

            - Randy