Making decade time-series
3 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have time-series data where smallest unit of time is 1 year (i.e. the series increases in yearly increments and there is no month value.
i.e.
1978
1979
1980
1801
How should I change the code to group by the series by decades?
dt = Year; % yearly increments
% How should the next line change for only yearly increases - no months?
[groups, groupID] = findgroups(floor(year(dt)/10)*10);
% Compute decade means and ignore NAN values
decMeans = splitapply(@(x)mean(x,'omitnan'),Precip,groups);
% Display results as a table
results = table(groupID.', decMeans.','VariableNames',{'Decade','MeanTemp'});
Thank you
1 件のコメント
Walter Roberson
2019 年 12 月 16 日
What is the difference between this question and your earlier https://www.mathworks.com/matlabcentral/answers/496771-find-timeseries-mean-for-10-years ?
回答 (1 件)
dpb
2019 年 12 月 16 日
roundyrs=fix(years(dt)/10)*10;
n=histc(roundyrs,min(roundyrs):10:max(roundyrs));
results in
>> [[min(roundyrs):10:max(roundyrs)].' n]
ans =
1800 1
1810 0
1820 0
1830 0
1840 0
1850 0
1860 0
1870 0
1880 0
1890 0
1900 0
1910 0
1920 0
1930 0
1940 0
1950 0
1960 0
1970 2
1980 1
>>
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Time Series についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!