gakonst icon

Untitled

gakonst | PRO | 02/19/18 08:59:14 PM UTC | 0 ⭐ | 230 👁️ | Never ⏰ | []
text |

990 B

|

None

|

0 👍

/

0 👎

close all;
clear all;
data = load('dat26v1.dat');
 % Get extremes, window of 50 samples
extrem = extremes(data, 0, 50);
 % get maxima indexes
% timeseries of maxima and of their corresponding times
maxima_inds = extrem(:, 3) == 1;
maxima = extrem(maxima_inds, :);
maxima_times = maxima(:,1);
maxima = maxima(:,2);
 n = length(maxima);
maxtau = 25;
alpha = 0.05;
zalpha = norminv(1-alpha/2);
 y = diff(maxima); % Time Series that We will work with, 1st order diff
 acM = autocorrelation(y, maxtau); 
autlim = zalpha/sqrt(n);
figure
clf
hold on
 for ii=1:maxtau
    plot(acM(ii+1,1)*[1 1],[0 acM(ii+1,2)],'b','linewidth',1.5)
end
plot([0 maxtau+1],[0 0],'k','linewidth',1.5)
plot([0 maxtau+1],autlim*[1 1],'--c','linewidth',1.5)
plot([0 maxtau+1],-autlim*[1 1],'--c','linewidth',1.5)
xlabel('\tau')
ylabel('r(\tau)')
title(sprintf('detrended time series by MA(%d) smooth, autocorrelation',maorder))
%---------------------------Show Autocorellation---------------------------

Comments