<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243607</link>
    <title>MATLAB Central Newsreader - how to sum up a series based on a defined interval</title>
    <description>Feed for thread: how to sum up a series based on a defined interval</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>Mon, 02 Feb 2009 23:06:02 -0500</pubDate>
      <title>how to sum up a series based on a defined interval</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243607#625568</link>
      <author>Kuo-Hsien </author>
      <description>Dear all,&lt;br&gt;
&lt;br&gt;
There is a series called &quot;value&quot; and it needs to be sum up based on an interval as below and then print out a new series.&lt;br&gt;
&amp;gt;&amp;gt; value = [1;2;3;4;NaN;6;7;8;9;NaN;11;12;13;NaN;15;16;17;18;19;20;21;22;23;24;25;26;NaN;28;29;30;31]&lt;br&gt;
&amp;gt;&amp;gt; interval=[4;3;4;3;4;3;4;3;3]&lt;br&gt;
&lt;br&gt;
For example,&lt;br&gt;
[1;2;3;4] for the 1st accumulation based on the 1st value [4] of interval matrix&lt;br&gt;
[NaN;6;7] for the 2nd accumulation based on the 2nd value [3] of interval matrix&lt;br&gt;
[8;9;NaN;11] for the 3rd accumulation based on the 3rd value [4] of interval matrix&lt;br&gt;
[12;13;NaN] for the 4th accumulation based on the 4th value [3] of interval matrix&lt;br&gt;
:&lt;br&gt;
:&lt;br&gt;
[25;26;NaN;28] for the 8th accumulation based on the 8th value [3] of interval matrix&lt;br&gt;
[29;30;31] for the 9th accumulation based on the 9th value [3] of interval matrix&lt;br&gt;
&lt;br&gt;
&amp;gt;&amp;gt; output = a new series after the each accumulations.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Please advice me. Thank you.&lt;br&gt;
&lt;br&gt;
Michael </description>
    </item>
    <item>
      <pubDate>Mon, 02 Feb 2009 23:23:01 -0500</pubDate>
      <title>Re: how to sum up a series based on a defined interval</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243607#625569</link>
      <author>Matt Fig</author>
      <description>mat2cell(value,interval)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
|`mfe||+slve|_i|Vqbrk^rbJ|$$=hq^fl^i^m|^l7`_dblq^Bbeljjl^|k</description>
    </item>
    <item>
      <pubDate>Tue, 03 Feb 2009 17:00:18 -0500</pubDate>
      <title>Re: how to sum up a series based on a defined interval</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/243607#625779</link>
      <author>Kuo-Hsien </author>
      <description>The length of dailyflux is &amp;lt;3288x1&amp;gt;.&lt;br&gt;
&lt;br&gt;
I know I probably mixed up in the length of matrix for mat2cell, but I cannot figure it out how to modify my code.&lt;br&gt;
&lt;br&gt;
Will you please give me a hint?&lt;br&gt;
Thanks,&lt;br&gt;
Michael&lt;br&gt;
&lt;br&gt;
%%%%%%%%&lt;br&gt;
??? Error using ==&amp;gt; mat2cell at 116&lt;br&gt;
Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [3288&lt;br&gt;
1].&lt;br&gt;
&lt;br&gt;
%%%%%%%%&lt;br&gt;
dailyflux_NT=CO2resp_daily_NT_m2&lt;br&gt;
for Year = 2000:2007&lt;br&gt;
days_per_weird_week=[]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for n = 1:12&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;days_per_weird_week = [days_per_weird_week ; 7 ; 7 ; 7 ; 7; rem(eomday(Year, n), 7) ]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ind = find(days_per_weird_week ~= 0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;days_per_weird_week = days_per_weird_week(ind)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for n = 1:length(days_per_weird_week)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dailyflux_NT(n)=sum{mat2cell(dailyflux_NT,days_per_weird_week)}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dailyflux_NT = [dailyflux_NT ; dailyflux_NT(n) / days_per_weird_week(n) * ones(days_per_weird_week(n), 1)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end</description>
    </item>
  </channel>
</rss>

