<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265106</link>
    <title>MATLAB Central Newsreader - average every 12th row of matrix</title>
    <description>Feed for thread: average every 12th row of matrix</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, 05 Nov 2009 17:19:03 -0500</pubDate>
      <title>average every 12th row of matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265106#692474</link>
      <author>Nix Nicholson</author>
      <description>Hi: Beginner question - I have 7 years of some monthly data fields and I want to compute the average for each month over the 7 year period. I can do it by specifying row numbers but how could I do this so that come next year, when i have 8 years data I can just change a scaler value for year number and it will recompute a new average?&lt;br&gt;
basically how do i compute a mean of every nth row, in my case every 12th.&lt;br&gt;
&lt;br&gt;
Many thanks</description>
    </item>
    <item>
      <pubDate>Thu, 05 Nov 2009 17:30:35 -0500</pubDate>
      <title>Re: average every 12th row of matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265106#692476</link>
      <author>the cyclist</author>
      <description>&quot;Nix Nicholson&quot; &amp;lt;linznix@gmail.com&amp;gt; wrote in message &amp;lt;hcv1e7$3ua$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi: Beginner question - I have 7 years of some monthly data fields and I want to compute the average for each month over the 7 year period. I can do it by specifying row numbers but how could I do this so that come next year, when i have 8 years data I can just change a scaler value for year number and it will recompute a new average?&lt;br&gt;
&amp;gt; basically how do i compute a mean of every nth row, in my case every 12th.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Many thanks&lt;br&gt;
&lt;br&gt;
You should be able to user the FILTER command to do this.</description>
    </item>
    <item>
      <pubDate>Thu, 05 Nov 2009 17:30:36 -0500</pubDate>
      <title>Re: average every 12th row of matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265106#692477</link>
      <author>Matt </author>
      <description>&quot;Nix Nicholson&quot; &amp;lt;linznix@gmail.com&amp;gt; wrote in message &amp;lt;hcv1e7$3ua$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi: Beginner question - I have 7 years of some monthly data fields and I want to compute the average for each month over the 7 year period. I can do it by specifying row numbers but how could I do this so that come next year, when i have 8 years data I can just change a scaler value for year number and it will recompute a new average?&lt;br&gt;
&amp;gt; basically how do i compute a mean of every nth row, in my case every 12th.&lt;br&gt;
&lt;br&gt;
Instead of organizing your data as a vector, you can organize it as an Nx12 matrix A where N is the number of years. Then do&lt;br&gt;
&lt;br&gt;
MonthlyMeans=mean(A,1);&lt;br&gt;
&lt;br&gt;
When you have N=8, just add a row and do the same thing.</description>
    </item>
    <item>
      <pubDate>Thu, 05 Nov 2009 17:26:55 -0500</pubDate>
      <title>Re: average every 12th row of matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265106#692478</link>
      <author>dpb</author>
      <description>Nix Nicholson wrote:&lt;br&gt;
&amp;gt; Hi: Beginner question - I have 7 years of some monthly data fields&lt;br&gt;
&amp;gt; and I want to compute the average for each month over the 7 year&lt;br&gt;
&amp;gt; period. I can do it by specifying row numbers but how could I do this&lt;br&gt;
&amp;gt; so that come next year, when i have 8 years data I can just change a&lt;br&gt;
&amp;gt; scaler value for year number and it will recompute a new average?&lt;br&gt;
&amp;gt; basically how do i compute a mean of every nth row, in my case every&lt;br&gt;
&amp;gt; 12th.&lt;br&gt;
...&lt;br&gt;
&lt;br&gt;
idx=1:12:length(x);&lt;br&gt;
avg = mean(idx,:);&lt;br&gt;
&lt;br&gt;
Salt to suit on selecting starting month, etc., ...&lt;br&gt;
&lt;br&gt;
--</description>
    </item>
    <item>
      <pubDate>Thu, 05 Nov 2009 18:32:02 -0500</pubDate>
      <title>Re: average every 12th row of matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265106#692496</link>
      <author>dpb</author>
      <description>dpb wrote:&lt;br&gt;
&amp;gt; Nix Nicholson wrote:&lt;br&gt;
&amp;gt;&amp;gt; Hi: Beginner question - I have 7 years of some monthly data fields&lt;br&gt;
&amp;gt;&amp;gt; and I want to compute the average for each month over the 7 year&lt;br&gt;
&amp;gt;&amp;gt; period. I can do it by specifying row numbers but how could I do this&lt;br&gt;
&amp;gt;&amp;gt; so that come next year, when i have 8 years data I can just change a&lt;br&gt;
&amp;gt;&amp;gt; scaler value for year number and it will recompute a new average?&lt;br&gt;
&amp;gt;&amp;gt; basically how do i compute a mean of every nth row, in my case every&lt;br&gt;
&amp;gt;&amp;gt; 12th.&lt;br&gt;
&amp;gt; ...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; idx=1:12:length(x);&lt;br&gt;
&amp;gt; avg = mean(idx,:);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Salt to suit on selecting starting month, etc., ...&lt;br&gt;
&lt;br&gt;
Should have been&lt;br&gt;
&lt;br&gt;
avg = mean(x(idx,:));&lt;br&gt;
&lt;br&gt;
of course...&lt;br&gt;
&lt;br&gt;
--</description>
    </item>
    <item>
      <pubDate>Thu, 01 Sep 2011 10:29:13 -0400</pubDate>
      <title>Re: average every 12th row of matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265106#851080</link>
      <author>Lindsey </author>
      <description>Hello, thanks to you all.&lt;br&gt;
&lt;br&gt;
I used dpb's solution written out as:&lt;br&gt;
&lt;br&gt;
for i=1:12; monthmean(i,:)=mean(x([i:12:end],:)); end&lt;br&gt;
&lt;br&gt;
where x is my original dataset with each row representing a month value and each column representing a variable.</description>
    </item>
  </channel>
</rss>

