Making decade time-series
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Walter Roberson
am 16 Dez. 2019
What is the difference between this question and your earlier https://www.mathworks.com/matlabcentral/answers/496771-find-timeseries-mean-for-10-years ?
Antworten (1)
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
>>
0 Kommentare
Siehe auch
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!