Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear;
- clc;
- close all;
- %
- load(fullfile(matlabroot,'examples','econ','Data_Accidental.mat'))
- %
- y = Data;
- T = length(y);
- years = linspace(1973,1979,T);
- ts = y;
- points_in_year = 12;
- %
- tim = (dates - dates(1))/(dates(2)-dates(1)); % <-- acquisition times for your *new* data, normalized
- NFpick = [2 7 13]; % <-- channels you picked to build the detrending baseline (peaks to be eliminated)
- % Compute the trend
- mu = mean(ts);
- Nchannels = length(ts); % <-- size of time domain data
- Mpick = 2*length(NFpick);
- X(:,1:2:Mpick) = cos(2*pi*(NFpick-1)'/Nchannels*tim')';
- X(:,2:2:Mpick) = sin(-2*pi*(NFpick-1)'/Nchannels*tim')';
- X = [ones(T,1), X];
- beta = Xts;
- trend = X*beta;
- detrended = y - trend + mu;
- figure
- plot(dates,detrended)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement