-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathandFunc.m
88 lines (56 loc) · 2.1 KB
/
andFunc.m
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
function eventRes = andFunc(nodeID,orData,startTime,stopTime )
psi1 = [];
psi2 = [];
% psi = [];
risingEdgs = [];
fallingEdgs = [];
psi1 = orData(1,:);
psi2 = orData(2,:);
psiRed1 = psi1{3};
psiFed1 = psi1{4};
psiRed2 = psi2{3};
psiFed2 = psi2{4};
if(~isempty(psiFed1))
if(psiFed1(length(psiFed1)) == -1)
psiFed1(length(psiFed1)) = stopTime + 1 ;
end
end
if(~isempty(psiFed2))
if(psiFed2(length(psiFed2)) == -1)
psiFed2(length(psiFed2)) = stopTime +1 ;
end
end
disp('and Func');
disp(psiRed1);
disp(psiFed1);
disp(psiRed2);
disp(psiFed2);
for i = 1 : length(psiRed1)
% tempRise = psiRed(i)-b;
for j = 1 : length(psiRed2)
% If we have overlap:
if(((psiRed1(i)>=psiRed2(j)) && (psiRed1(i)<=psiFed2(j))) || ((psiFed1(i)>=psiRed2(j)) && (psiFed1(i)<=psiFed2(j)))|| ((psiRed2(j)>=psiRed1(i)) && (psiRed2(j)<=psiFed1(i)))|| ((psiFed2(j)>=psiRed1(i)) && (psiFed2(j)<=psiFed1(i))))
if(isempty(risingEdgs))
risingEdgs =[risingEdgs,max(psiRed1(i),psiRed2(j))];
fallingEdgs =[fallingEdgs,min(psiFed1(i),psiFed2(j))];
else
if (max(psiRed1(i),psiRed2(j)) > risingEdgs(length(risingEdgs)))
risingEdgs =[risingEdgs,max(psiRed1(i),psiRed2(j))];
end
if (min(psiFed1(i),psiFed2(j)) > fallingEdgs(length(fallingEdgs)))
fallingEdgs =[fallingEdgs,min(psiFed1(i),psiFed2(j))];
%
% elseif ((psiRed1(i)~=-1)||(psiRed2(j)~=-1))
% fallingEdgs =[fallingEdgs,-1];
end
end
end
end
end
if(~isempty(fallingEdgs))
if(fallingEdgs(length(fallingEdgs)) == (stopTime + 1))
fallingEdgs(length(fallingEdgs))= -1 ;
end
end
eventRes = {nodeID,3,risingEdgs,fallingEdgs};
end