Seasonal Variability of time series

5 vues (au cours des 30 derniers jours)
Aoyi
Aoyi le 6 Mai 2018
I would like to find out the seasonal variability of the data. My data is form 1883-2018 temperature. Each month has several data. I tried to calculate the average of each month and do the seasonal variation. But I got NaN for sst. Here is my code.
MIDAS00525temp = load('../TimeseriesProject/MIDAS_srcid00525_daily_temperature.txt');
tempmin = MIDAS00525temp (:,3);
tempmin(tempmin<0) = NaN; MATLABDate_temp = MIDAS00525temp(:,2);
tempfilled = inpaint_nans(tempmin, 3);
[Y,M] = datevec(MIDAS00525temp(:,2));
[a,~,c] = unique([Y,M],'rows'); yearaveragemin = [a, accumarray(c,MIDAS00525temp(:,3),[],@(x)mean(x))];
datayearaveragemin = (yearaveragemin(:,3));
MATLABDate_temp = datenum(yearaveragemin(:,1), yearaveragemin(:,2), 0);
% Make a moving average
temp_medfiltmin = medfilt1(datayearaveragemin, 36, 'omitnan', 'truncate'); xt = datayearaveragemin - temp_medfiltmin; T = length(MATLABDate_temp);
% Create seasonal indices
s = 12; % number of timesteps per year sidx = cell(s,1); for i = 1:s sidx{i,1} = i:s:T; end % Apply a stable seasonal filter.
sst = cellfun(@(x) mean(xt(x)),sidx);

Réponses (0)

Catégories

En savoir plus sur Risk Management Toolbox 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!

Translated by