Filter löschen
Filter löschen

Making decade time-series

3 Ansichten (letzte 30 Tage)
Sarah Yun
Sarah Yun am 16 Dez. 2019
Beantwortet: dpb am 16 Dez. 2019
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

Antworten (1)

dpb
dpb am 16 Dez. 2019
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
>>

Kategorien

Mehr zu Time Series finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by