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!
[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에서 Dynamic System Models에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by