-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgloballyFunc.m
107 lines (73 loc) · 1.84 KB
/
globallyFunc.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
function globRes = globallyFunc(nodeID,globData,lower,upper,startTime,stopTime )
finalRise=-2;
finalFall=-2;
psi = [];
risingEdgs = [];
fallingEdges = [];
a = lower;
b = upper;
psi = globData(1,:);
disp('G');
disp(psi{1,3});
disp(psi{1,4});
risFlag = 0;
falFlag = 0;
psiRed = psi{3};
psiFed = psi{4};
% if the signal starts with a falling edge
if (length(psiRed)>=1)
if(psiRed(1)==-1)
risFlag = 1;
end
end
% if the signal stops with a rising edge
if (length(psiFed)>=1)
if(psiFed(length(psiFed))==-1)
falFlag = 1;
end
end
for i=1 : min(length(psiRed),length(psiFed))
% Calculating a new rising edge
if ((a == 1 )&& (risFlag == 1) && (psiRed(i) == -1) )
tempRise = -2;
else
tempRise = psiRed(i)-a;
end
if (tempRise >= startTime)
finalRise = tempRise;
else
finalRise = -2;
end
% calculating a new falling edge
if(falFlag == 1 && psiFed(i)==-1)
tempFall = stopTime - b;
else
tempFall = psiFed(i) - b;
end
if (tempFall >= startTime)
finalFall = tempFall;
else
finalFall = -2;
end
if (tempRise<0 && tempFall<0)
finalRise=-2;
finalFall=-2;
end
if (tempRise==tempFall)
finalRise=-2;
finalFall=-2;
end
if(finalRise==-2 && (finalRise<finalFall && psiRed(i)==-1))
risingEdgs = [risingEdgs, psiRed(i)];
end
if(finalRise~=-2 && finalRise<finalFall)
risingEdgs = [risingEdgs,finalRise];
end
if(finalFall~=-2 && finalRise<finalFall)
fallingEdges = [fallingEdges,finalFall];
end
finalRise=-2;
finalFall=-2;
end
globRes = {nodeID,3,risingEdgs,fallingEdges};
end