time series 30 year sliding window
Afficher commentaires plus anciens
I have a set of daily data that ranges from the years 1772-2009. The data is currently in an array that has one column as the date number and one column as my data. I want to set 30 year sliding windows for this data moving a year on every time. For example I want the data to be in an array where the first column has all the data from 1772-1801, the 2nd has all the data from 1773-1802 and so on.
Each value has a corresponding date to it (year, month and day). It would be nice to be able to program MATLAB to take all the values corresponding to the years in the ranges I need.
For example I want to say something along these lines, I just dont know the exact code or if what I want to do is even possible: I already have data = my daily data
for y=1772:1979
30yearperiods(:,1,2,3...207) = temp (dependent on year== n to n+30)
Does anyone know how I can do this?
I have had major problems trying to set for loops that encompass the 30 year periods including all the leap years etc and its frustrating having to do this when I have the data I need and I just can't extreact it
Réponse acceptée
Plus de réponses (1)
bahman rostami tabar
le 20 Déc 2011
you can easily use this code:
% where data is your column data vector
% m is window length so for your case m=30;
OverlapAggregateVector=zeros(m, size(data,1)-m+1);
for k=1:m
OverlapAggregateVector(k,:)=data(k:end-m+k,1);
end
Catégories
En savoir plus sur Dates and Time dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!