<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644</link>
    <title>MATLAB Central Newsreader - Moving averages over a vector in MatLAB?</title>
    <description>Feed for thread: Moving averages over a vector in MatLAB?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 01 Nov 2007 16:21:38 -0400</pubDate>
      <title>Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399444</link>
      <author>Erik Carlsten</author>
      <description>Hi everyone, recently I have been doing some analysis on &lt;br&gt;
some FFTS trying to find and analyze regions with peaks. &lt;br&gt;
One thing we have been doing to make this process easier &lt;br&gt;
is to take a moving average of the FFT before analyzing &lt;br&gt;
the peaks to ensure that rogue spikes in our FFTs do not &lt;br&gt;
mislead our signal processing. However, one problem I am &lt;br&gt;
forseeing is just how slow our current moving average is. &lt;br&gt;
Currently we are simply looking at x points on the left &lt;br&gt;
side and x points on the right side of our current point &lt;br&gt;
and taking a mean of that data and then setting the same &lt;br&gt;
index in our new smoothed out FFT vector to be that mean &lt;br&gt;
value. I would like to see if anyone knows a slick way to &lt;br&gt;
accomplish this with either a built in toolbox function or &lt;br&gt;
if there is a way to apply a custom written function to &lt;br&gt;
each index in a vector without a for loop.&lt;br&gt;
&lt;br&gt;
Below is some code that is similar to what we are &lt;br&gt;
currently using to accomplish our FFT smoothing process. &lt;br&gt;
FFTVect represents our intensity values at a given &lt;br&gt;
frequency. We are simply trying to build a new &quot;smoothed &lt;br&gt;
out&quot; FFT that does not show any thin but tall spikes that &lt;br&gt;
our original FFT shows. This averaging process eliminates &lt;br&gt;
this issue previous to our peak analysis but the way we &lt;br&gt;
are currently doing it seems very slow and clunky. Any &lt;br&gt;
suggestions?&lt;br&gt;
&lt;br&gt;
avgWin = 10;&lt;br&gt;
&lt;br&gt;
avgFFT = FFTvect;&lt;br&gt;
&lt;br&gt;
for index = avgWin+1:length(avgFFT)-avgWin&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;avgFFT(index) = mean(FFTVect(index-&lt;br&gt;
avgWin:index+avgWin));&lt;br&gt;
end</description>
    </item>
    <item>
      <pubDate>Thu, 01 Nov 2007 16:36:30 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399452</link>
      <author>dpb</author>
      <description>Erik Carlsten wrote:&lt;br&gt;
&amp;gt; Hi everyone, recently I have been doing some analysis on &lt;br&gt;
&amp;gt; some FFTS trying to find and analyze regions with peaks. &lt;br&gt;
&amp;gt; One thing we have been doing to make this process easier &lt;br&gt;
&amp;gt; is to take a moving average of the FFT before analyzing ...&lt;br&gt;
&lt;br&gt;
lookfor filter&lt;br&gt;
&lt;br&gt;
Depending on which toolbox(es) you have, results can vary widely, of &lt;br&gt;
course...&lt;br&gt;
&lt;br&gt;
--</description>
    </item>
    <item>
      <pubDate>Thu, 01 Nov 2007 16:44:02 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399453</link>
      <author> Randy Poe</author>
      <description>On Nov 1, 12:21 pm, &quot;Erik Carlsten&quot; &amp;lt;ecarl...@yahoo.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi everyone, recently I have been doing some analysis on&lt;br&gt;
&amp;gt; some FFTS trying to find and analyze regions with peaks.&lt;br&gt;
&amp;gt; One thing we have been doing to make this process easier&lt;br&gt;
&amp;gt; is to take a moving average of the FFT before analyzing&lt;br&gt;
&amp;gt; the peaks to ensure that rogue spikes in our FFTs do not&lt;br&gt;
&amp;gt; mislead our signal processing. However, one problem I am&lt;br&gt;
&amp;gt; forseeing is just how slow our current moving average is.&lt;br&gt;
&amp;gt; Currently we are simply looking at x points on the left&lt;br&gt;
&amp;gt; side and x points on the right side of our current point&lt;br&gt;
&amp;gt; and taking a mean of that data and then setting the same&lt;br&gt;
&amp;gt; index in our new smoothed out FFT vector to be that mean&lt;br&gt;
&amp;gt; value. I would like to see if anyone knows a slick way to&lt;br&gt;
&amp;gt; accomplish this with either a built in toolbox function or&lt;br&gt;
&amp;gt; if there is a way to apply a custom written function to&lt;br&gt;
&amp;gt; each index in a vector without a for loop.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Below is some code that is similar to what we are&lt;br&gt;
&amp;gt; currently using to accomplish our FFT smoothing process.&lt;br&gt;
&amp;gt; FFTVect represents our intensity values at a given&lt;br&gt;
&amp;gt; frequency. We are simply trying to build a new &quot;smoothed&lt;br&gt;
&amp;gt; out&quot; FFT that does not show any thin but tall spikes that&lt;br&gt;
&amp;gt; our original FFT shows. This averaging process eliminates&lt;br&gt;
&amp;gt; this issue previous to our peak analysis but the way we&lt;br&gt;
&amp;gt; are currently doing it seems very slow and clunky. Any&lt;br&gt;
&amp;gt; suggestions?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; avgWin = 10;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; avgFFT = FFTvect;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; for index = avgWin+1:length(avgFFT)-avgWin&lt;br&gt;
&amp;gt;     avgFFT(index) = mean(FFTVect(index-&lt;br&gt;
&amp;gt; avgWin:index+avgWin));&lt;br&gt;
&amp;gt; end&lt;br&gt;
&lt;br&gt;
This is a convolution with the rectangular&lt;br&gt;
window function [1/N 1/N .... 1/N]. Look up&lt;br&gt;
CONV or FILTER.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Randy</description>
    </item>
    <item>
      <pubDate>Thu, 01 Nov 2007 17:15:28 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399456</link>
      <author>Dave Robinson</author>
      <description>&amp;nbsp;Randy Poe &amp;lt;poespam-trap@yahoo.com&amp;gt; wrote in message &lt;br&gt;
&amp;lt;1193935442.969959.94480@50g2000hsm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On Nov 1, 12:21 pm, &quot;Erik Carlsten&quot; &amp;lt;ecarl...@yahoo.com&amp;gt; &lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; &amp;gt; Hi everyone, recently I have been doing some analysis on&lt;br&gt;
&amp;gt; &amp;gt; some FFTS trying to find and analyze regions with peaks.&lt;br&gt;
&amp;gt; &amp;gt; One thing we have been doing to make this process easier&lt;br&gt;
&amp;gt; &amp;gt; is to take a moving average of the FFT before analyzing&lt;br&gt;
&amp;gt; &amp;gt; the peaks to ensure that rogue spikes in our FFTs do not&lt;br&gt;
&amp;gt; &amp;gt; mislead our signal processing. However, one problem I am&lt;br&gt;
&amp;gt; &amp;gt; forseeing is just how slow our current moving average &lt;br&gt;
is.&lt;br&gt;
&amp;gt; &amp;gt; Currently we are simply looking at x points on the left&lt;br&gt;
&amp;gt; &amp;gt; side and x points on the right side of our current point&lt;br&gt;
&amp;gt; &amp;gt; and taking a mean of that data and then setting the same&lt;br&gt;
&amp;gt; &amp;gt; index in our new smoothed out FFT vector to be that mean&lt;br&gt;
&amp;gt; &amp;gt; value. I would like to see if anyone knows a slick way &lt;br&gt;
to&lt;br&gt;
&amp;gt; &amp;gt; accomplish this with either a built in toolbox function &lt;br&gt;
or&lt;br&gt;
&amp;gt; &amp;gt; if there is a way to apply a custom written function to&lt;br&gt;
&amp;gt; &amp;gt; each index in a vector without a for loop.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Below is some code that is similar to what we are&lt;br&gt;
&amp;gt; &amp;gt; currently using to accomplish our FFT smoothing process.&lt;br&gt;
&amp;gt; &amp;gt; FFTVect represents our intensity values at a given&lt;br&gt;
&amp;gt; &amp;gt; frequency. We are simply trying to build a new &quot;smoothed&lt;br&gt;
&amp;gt; &amp;gt; out&quot; FFT that does not show any thin but tall spikes &lt;br&gt;
that&lt;br&gt;
&amp;gt; &amp;gt; our original FFT shows. This averaging process &lt;br&gt;
eliminates&lt;br&gt;
&amp;gt; &amp;gt; this issue previous to our peak analysis but the way we&lt;br&gt;
&amp;gt; &amp;gt; are currently doing it seems very slow and clunky. Any&lt;br&gt;
&amp;gt; &amp;gt; suggestions?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; avgWin = 10;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; avgFFT = FFTvect;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; for index = avgWin+1:length(avgFFT)-avgWin&lt;br&gt;
&amp;gt; &amp;gt;     avgFFT(index) = mean(FFTVect(index-&lt;br&gt;
&amp;gt; &amp;gt; avgWin:index+avgWin));&lt;br&gt;
&amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This is a convolution with the rectangular&lt;br&gt;
&amp;gt; window function [1/N 1/N .... 1/N]. Look up&lt;br&gt;
&amp;gt; CONV or FILTER.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;             - Randy&lt;br&gt;
&amp;gt; &lt;br&gt;
Just a thought here, if you are convolving with a &lt;br&gt;
rectangular window in the frequency domain, isn't that &lt;br&gt;
simply a multiplication with a sync function in the time &lt;br&gt;
domain, which must be a lot faster.&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
&lt;br&gt;
Dave Robinson</description>
    </item>
    <item>
      <pubDate>Thu, 01 Nov 2007 17:44:01 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399460</link>
      <author>Malcolm Lidierth</author>
      <description>Why not just shorten the length of the fft so the resulting &lt;br&gt;
bins are wider? You would then also have more sections to &lt;br&gt;
average if you are forming a periodogram.</description>
    </item>
    <item>
      <pubDate>Thu, 01 Nov 2007 18:29:21 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399463</link>
      <author>Erik Carlsten</author>
      <description>&quot;Malcolm Lidierth&quot; &amp;lt;ku.ca.lck@htreidil.mloclam&amp;gt; wrote in &lt;br&gt;
message &amp;lt;fgd391$kds$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Why not just shorten the length of the fft so the &lt;br&gt;
resulting &lt;br&gt;
&amp;gt; bins are wider? You would then also have more sections &lt;br&gt;
to &lt;br&gt;
&amp;gt; average if you are forming a periodogram.&lt;br&gt;
&lt;br&gt;
When I am taking the average of my FFT, I am not actually &lt;br&gt;
taking an average of the entire FFT. The entire FFT shows &lt;br&gt;
a frequency domain of 0-3600Hz and I am only interested in &lt;br&gt;
the shape of the FFT for frequencies between 100-400Hz. I &lt;br&gt;
will of course only take a moving average of the 100-400Hz &lt;br&gt;
range for speed considerations but I was just throwing &lt;br&gt;
this general question out there to see if anyone had any &lt;br&gt;
ideas on how to go about taking the moving average of a &lt;br&gt;
vector.</description>
    </item>
    <item>
      <pubDate>Thu, 01 Nov 2007 18:32:30 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399465</link>
      <author>Erik Carlsten</author>
      <description>&quot;Malcolm Lidierth&quot; &amp;lt;ku.ca.lck@htreidil.mloclam&amp;gt; wrote in &lt;br&gt;
message &amp;lt;fgd391$kds$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Why not just shorten the length of the fft so the &lt;br&gt;
resulting &lt;br&gt;
&amp;gt; bins are wider? You would then also have more sections &lt;br&gt;
to &lt;br&gt;
&amp;gt; average if you are forming a periodogram.&lt;br&gt;
&lt;br&gt;
I think I misunderstood what you meant during my first &lt;br&gt;
reply. Are you referring to simply changing the overall &lt;br&gt;
resolution when I convert my data over the time domain &lt;br&gt;
into an FFT? So that way my FFT returns a vector over the &lt;br&gt;
frequency domain of say 2048 bins rather than 4096 so the &lt;br&gt;
FFT appears to be smoother?</description>
    </item>
    <item>
      <pubDate>Thu, 01 Nov 2007 18:34:01 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399466</link>
      <author> Randy Poe</author>
      <description>On Nov 1, 1:15 pm, &quot;Dave Robinson&quot; &amp;lt;dave.robin...@somewhere.biz&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt;  Randy Poe &amp;lt;poespam-t...@yahoo.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;1193935442.969959.94...@50g2000hsm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; On Nov 1, 12:21 pm, &quot;Erik Carlsten&quot; &amp;lt;ecarl...@yahoo.com&amp;gt;&lt;br&gt;
&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi everyone, recently I have been doing some analysis on&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; some FFTS trying to find and analyze regions with peaks.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; One thing we have been doing to make this process easier&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; is to take a moving average of the FFT before analyzing&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; the peaks to ensure that rogue spikes in our FFTs do not&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; mislead our signal processing. However, one problem I am&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; forseeing is just how slow our current moving average&lt;br&gt;
&amp;gt; is.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Currently we are simply looking at x points on the left&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; side and x points on the right side of our current point&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; and taking a mean of that data and then setting the same&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; index in our new smoothed out FFT vector to be that mean&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; value. I would like to see if anyone knows a slick way&lt;br&gt;
&amp;gt; to&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; accomplish this with either a built in toolbox function&lt;br&gt;
&amp;gt; or&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; if there is a way to apply a custom written function to&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; each index in a vector without a for loop.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Below is some code that is similar to what we are&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; currently using to accomplish our FFT smoothing process.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; FFTVect represents our intensity values at a given&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; frequency. We are simply trying to build a new &quot;smoothed&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; out&quot; FFT that does not show any thin but tall spikes&lt;br&gt;
&amp;gt; that&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; our original FFT shows. This averaging process&lt;br&gt;
&amp;gt; eliminates&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; this issue previous to our peak analysis but the way we&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; are currently doing it seems very slow and clunky. Any&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; suggestions?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; avgWin = 10;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; avgFFT = FFTvect;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; for index = avgWin+1:length(avgFFT)-avgWin&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt;     avgFFT(index) = mean(FFTVect(index-&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; avgWin:index+avgWin));&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; This is a convolution with the rectangular&lt;br&gt;
&amp;gt; &amp;gt; window function [1/N 1/N .... 1/N]. Look up&lt;br&gt;
&amp;gt; &amp;gt; CONV or FILTER.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Just a thought here, if you are convolving with a&lt;br&gt;
&amp;gt; rectangular window in the frequency domain, isn't that&lt;br&gt;
&amp;gt; simply a multiplication with a sync function in the time&lt;br&gt;
&amp;gt; domain, which must be a lot faster.&lt;br&gt;
&lt;br&gt;
I believe that CONV and FILTER both use that approach,&lt;br&gt;
but do all the index bookkeeping for you. That's why&lt;br&gt;
I suggested them. I may be wrong on CONV however,&lt;br&gt;
because it does append those extra elements at the&lt;br&gt;
beginning and end.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;- Randy</description>
    </item>
    <item>
      <pubDate>Fri, 02 Nov 2007 11:32:05 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399567</link>
      <author>Malcolm Lidierth</author>
      <description>Erik&lt;br&gt;
Yes. Reducing the length of the FFT allows you to divide &lt;br&gt;
the data into more sections. This does not reduce noise of &lt;br&gt;
the individual FFTs- fewer points out, but also fewer in, &lt;br&gt;
so the coefficient of variation stays at ~100%. However, &lt;br&gt;
averaging the FFTs decreases the noise by the square root &lt;br&gt;
of the number of data sections (i.e. FFTs). This is the &lt;br&gt;
basis of the PWELCH function in the Signal Processing &lt;br&gt;
Toolbox. See &lt;br&gt;
&lt;a href=&quot;http://www.nrbook.com/a/bookcpdf.php&quot;&gt;http://www.nrbook.com/a/bookcpdf.php&lt;/a&gt;&lt;br&gt;
Chapter 13.&lt;br&gt;
&lt;br&gt;
Filtering the data as you suggest might be OK but it &lt;br&gt;
depends on how you have corrected for the window: if you &lt;br&gt;
have a spectral density OK, but if it is a spectrum then &lt;br&gt;
only the peaks in your result are meaningful. &lt;br&gt;
See&lt;br&gt;
&lt;a href=&quot;http://www.rssd.esa.int/SP/LISAPATHFINDER/docs/Data_Analysis&quot;&gt;http://www.rssd.esa.int/SP/LISAPATHFINDER/docs/Data_Analysis&lt;/a&gt;&lt;br&gt;
/GH_FFT.pdf</description>
    </item>
    <item>
      <pubDate>Fri, 02 Nov 2007 19:38:26 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399633</link>
      <author>Erik Carlsten</author>
      <description>Thanks very much to everyone that responded. I ended up &lt;br&gt;
using filter() for my solution and it decreased the time &lt;br&gt;
in my running average by over a factor of 200. Needless to &lt;br&gt;
say this is exactly what I was looking for!&lt;br&gt;
&lt;br&gt;
windowSize = avgWin*2+1;&lt;br&gt;
avgFFTNoise = filter(ones(1,windowSize)/windowSize, 1, ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rangeMinusNoiseY(cutIndexRange+avgWin));&lt;br&gt;
&lt;br&gt;
Thanks Randy for the suggestion to use filter() to take &lt;br&gt;
the running average it worked great!</description>
    </item>
    <item>
      <pubDate>Fri, 02 Nov 2007 20:09:24 -0400</pubDate>
      <title>Re: Moving averages over a vector in MatLAB?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/158644#399639</link>
      <author> Eric C</author>
      <description>On Nov 2, 3:38 pm, &quot;Erik Carlsten&quot; &amp;lt;ecarl...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Thanks very much to everyone that responded. I ended up&lt;br&gt;
&amp;gt; using filter() for my solution and it decreased the time&lt;br&gt;
&amp;gt; in my running average by over a factor of 200. Needless to&lt;br&gt;
&amp;gt; say this is exactly what I was looking for!&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; windowSize = avgWin*2+1;&lt;br&gt;
&amp;gt; avgFFTNoise = filter(ones(1,windowSize)/windowSize, 1, ...&lt;br&gt;
&amp;gt;         rangeMinusNoiseY(cutIndexRange+avgWin));&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks Randy for the suggestion to use filter() to take&lt;br&gt;
&amp;gt; the running average it worked great!&lt;br&gt;
&lt;br&gt;
If I understand correctly this can be implemented very efficiently.&lt;br&gt;
Think of it this way, after you've computed the mean of all the&lt;br&gt;
samples in your window you then move it one point forward. All that&lt;br&gt;
really does is add a new sample to your mean and subtract the last&lt;br&gt;
one. That means you've got an integrating filter and a differencing&lt;br&gt;
filter, with a delay, and no multiplies. This is the basic idea behind&lt;br&gt;
CIC filters, just without the decimation. Look up CIC filters and you&lt;br&gt;
should get the idea, I found part of Fred Harris' Multirate book&lt;br&gt;
online had the best explanation, but I can't find it now.</description>
    </item>
  </channel>
</rss>

