-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDeNoising.m
60 lines (59 loc) · 1.47 KB
/
DeNoising.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
% A filter that works according to the average of the nearest members.
% Very similar to a moving average.
% Not used, but tested and failed with noisy signals.
function G = DeNoising(Y)
nirmul = 1/4;
for i = 1:length(Y(:,1))
for j = 1:2
if (Y(i,1)>1.1) % lines 6-20 to normalize the first member.
Y(i,1) = (Y(i,2) + Y(i,3)...
+ Y(i,4) + Y(i,5))*nirmul;
if (Y(i,1)>1.1)
Y(i,:) = 0;
break
end
elseif(Y(i,1)<-0.2)
Y(i,1) = (Y(i,2) + Y(i,3)...
+ Y(i,4) + Y(i,5))*nirmul;
if (Y(i,1)<-0.2)
Y(i,:) = 0;
break
end
end
if (Y(i,2)>1.1) % lines 21-35 to normalize the second member.
Y(i,2) = (Y(i,1) + Y(i,3)...
+ Y(i,4) + Y(i,5))*nirmul;
if (Y(i,2)>1.1)
Y(i,:) = 0;
break
end
elseif(Y(i,2)<-0.2)
Y(i,2) = (Y(i,1) + Y(i,3)...
+ Y(i,4) + Y(i,5))*nirmul;
if (Y(i,2)<-0.2)
Y(i,:) = 0;
break
end
end
for j = 3:length(Y(1,:))-4
if (Y(i,j)>1.1)
Y(i,j) = (Y(i,j-1) + Y(i,j-2)...
+ Y(i,j+1) + Y(i,j+2))*nirmul;
if (Y(i,j)>1.1)
Y(i,:) = 0;
break
end
elseif (Y(i,j)<-0.2)
Y(i,j) = (Y(i,j-1) + Y(i,j-2)...
+ Y(i,j+1) + Y(i,j+2))*nirmul;
if (Y(i,j)<-0.2)
Y(i,:) = 0;
break
end
end
end
end
end
Y(~any(Y,2), : ) = [];
G = Y;
end