Thread Subject: how to sum up a series based on a defined interval

Subject: how to sum up a series based on a defined interval

From: Kuo-Hsien

Date: 2 Feb, 2009 23:06:02

Message: 1 of 3

Dear all,

There is a series called "value" and it needs to be sum up based on an interval as below and then print out a new series.
>> 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]
>> interval=[4;3;4;3;4;3;4;3;3]

For example,
[1;2;3;4] for the 1st accumulation based on the 1st value [4] of interval matrix
[NaN;6;7] for the 2nd accumulation based on the 2nd value [3] of interval matrix
[8;9;NaN;11] for the 3rd accumulation based on the 3rd value [4] of interval matrix
[12;13;NaN] for the 4th accumulation based on the 4th value [3] of interval matrix
:
:
[25;26;NaN;28] for the 8th accumulation based on the 8th value [3] of interval matrix
[29;30;31] for the 9th accumulation based on the 9th value [3] of interval matrix

>> output = a new series after the each accumulations.


Please advice me. Thank you.

Michael

Subject: how to sum up a series based on a defined interval

From: Matt Fig

Date: 2 Feb, 2009 23:23:01

Message: 2 of 3

mat2cell(value,interval)




|`mfe||+slve|_i|Vqbrk^rbJ|$$=hq^fl^i^m|^l7`_dblq^Bbeljjl^|k

Subject: how to sum up a series based on a defined interval

From: Kuo-Hsien

Date: 3 Feb, 2009 17:00:18

Message: 3 of 3

The length of dailyflux is <3288x1>.

I know I probably mixed up in the length of matrix for mat2cell, but I cannot figure it out how to modify my code.

Will you please give me a hint?
Thanks,
Michael

%%%%%%%%
??? Error using ==> mat2cell at 116
Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [3288
1].

%%%%%%%%
dailyflux_NT=CO2resp_daily_NT_m2
for Year = 2000:2007
days_per_weird_week=[]
    for n = 1:12
        days_per_weird_week = [days_per_weird_week ; 7 ; 7 ; 7 ; 7; rem(eomday(Year, n), 7) ]
    end
end

    ind = find(days_per_weird_week ~= 0)
    days_per_weird_week = days_per_weird_week(ind)
    
    for n = 1:length(days_per_weird_week)
        dailyflux_NT(n)=sum{mat2cell(dailyflux_NT,days_per_weird_week)}
        dailyflux_NT = [dailyflux_NT ; dailyflux_NT(n) / days_per_weird_week(n) * ones(days_per_weird_week(n), 1)]
    end

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com