Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. clear;
  2. clc;
  3. close all;
  4. %
  5. load(fullfile(matlabroot,'examples','econ','Data_Accidental.mat'))
  6. %
  7. y = Data;
  8. T = length(y);
  9. years = linspace(1973,1979,T);
  10. ts = y;
  11. points_in_year = 12;
  12. %
  13. tim = (dates - dates(1))/(dates(2)-dates(1)); % <-- acquisition times for your *new* data, normalized
  14. NFpick = [2 7 13]; % <-- channels you picked to build the detrending baseline (peaks to be eliminated)
  15. % Compute the trend
  16. mu = mean(ts);
  17. Nchannels = length(ts); % <-- size of time domain data
  18. Mpick = 2*length(NFpick);
  19. X(:,1:2:Mpick) = cos(2*pi*(NFpick-1)'/Nchannels*tim')';
  20. X(:,2:2:Mpick) = sin(-2*pi*(NFpick-1)'/Nchannels*tim')';
  21. X = [ones(T,1), X];
  22. beta = Xts;
  23. trend = X*beta;
  24. detrended = y - trend + mu;
  25. figure
  26. plot(dates,detrended)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement