Hi
I have time series. I want to stack monthly(hist). I need to count how many times my time series repeated in every month for given long period and stack each month results. January+January, February+February, March+March..... Such as January would be repeated 250, February 300, March 280.......
(Please see attached excel file).
Thanks a lot!

 採用された回答

Andrei Bobrov
Andrei Bobrov 2017 年 3 月 24 日

1 投票

[~,~,c] = xlsread('stack_monthly.xlsx');
[y,m] = datevec(c,'yyyy-mm-ddTHH:MM:SS.FFFZ');
a = unique([y,m],'rows');
out = accumarray(a(:,2),1);

4 件のコメント

davit petraasya
davit petraasya 2017 年 3 月 24 日
Thank you Andrei! It worked.
davit petraasya
davit petraasya 2017 年 3 月 29 日
編集済み: davit petraasya 2017 年 3 月 29 日
Hi Andrei, can you do me one more favor,please? Now I have values corresponding to months. How I may stack monthly values?(Attached file)
Thank you!
Andrei Bobrov
Andrei Bobrov 2017 年 3 月 29 日
[d,~,c] = xlsread('stack_montlyvalues.xlsx');
[~,m] = datevec(c(:,1),'yyyy-mm-ddTHH:MM:SS.FFFZ');
[a,~,ii] = unique(m);
out = [a,accumarray(ii,d)];
davit petraasya
davit petraasya 2017 年 4 月 3 日
Thanks a lot for your help again Andrei. Code is working!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by