Seasonal Variability of time series
1 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!