-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacfhelper.m
More file actions
44 lines (37 loc) · 1.01 KB
/
acfhelper.m
File metadata and controls
44 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function [m,s] = acfhelper(D,lag)
%ACFHELPER Summary of this function goes here
% Finds the autocorrelation per error type (row) per node (column) and
% stores it in 2 matrices. One matrix includes error types and nodes and
% the autocorrelation values and the other the lag/step associated with the highest acf value
% to capture time-of-day effect
b = size(D,2);
a = size(D,1);
s = zeros(b,a);
m = zeros(b,a);
for i=1:size(D,2)
temp = D(:,i,:);
temp = permute(temp,[1 3 2]);
for j=1:size(temp,1)
yt = temp(j,:);
if(nnz(yt)>0)
yt = transpose(yt);
myacf = acf(yt,lag);
mx = max(myacf);
mi = find(myacf==mx);
m(i,j) = round(mx,3);
if isempty(mi)
s(i,j) = 0;
else
if mx> 0.04
s(i,j) = mi(1);
else
s(i,j) = 0;
end
end
else
m(i,j) = 0;
s(i,j) = 0;
end
end
end
end