Seasonal Variability of time series
조회 수: 2 (최근 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에서 Descriptive Statistics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!