Making decade time-series
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Walter Roberson
le 16 Déc 2019
What is the difference between this question and your earlier https://www.mathworks.com/matlabcentral/answers/496771-find-timeseries-mean-for-10-years ?
Réponses (1)
dpb
le 16 Déc 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 commentaires
Voir également
Catégories
En savoir plus sur Time Series dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!