gakonst

Untitled

Feb 19th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. close all;
  2. clear all;
  3. data = load('dat26v1.dat');
  4.  
  5. % Get extremes, window of 50 samples
  6. extrem = extremes(data, 0, 50);
  7.  
  8. % get maxima indexes
  9. % timeseries of maxima and of their corresponding times
  10. maxima_inds = extrem(:, 3) == 1;
  11. maxima = extrem(maxima_inds, :);
  12. maxima_times = maxima(:,1);
  13. maxima = maxima(:,2);
  14.  
  15. n = length(maxima);
  16. maxtau = 25;
  17. alpha = 0.05;
  18. zalpha = norminv(1-alpha/2);
  19.  
  20. y = diff(maxima); % Time Series that We will work with, 1st order diff
  21.  
  22. acM = autocorrelation(y, maxtau);
  23. autlim = zalpha/sqrt(n);
  24. figure
  25. clf
  26. hold on
  27.  
  28. for ii=1:maxtau
  29. plot(acM(ii+1,1)*[1 1],[0 acM(ii+1,2)],'b','linewidth',1.5)
  30. end
  31. plot([0 maxtau+1],[0 0],'k','linewidth',1.5)
  32. plot([0 maxtau+1],autlim*[1 1],'--c','linewidth',1.5)
  33. plot([0 maxtau+1],-autlim*[1 1],'--c','linewidth',1.5)
  34. xlabel('\tau')
  35. ylabel('r(\tau)')
  36. title(sprintf('detrended time series by MA(%d) smooth, autocorrelation',maorder))
  37. %---------------------------Show Autocorellation---------------------------
Advertisement
Add Comment
Please, Sign In to add comment