-
Notifications
You must be signed in to change notification settings - Fork 0
/
keepsmalldif.m
32 lines (26 loc) · 913 Bytes
/
keepsmalldif.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
function [temp_array1,temp_array2] = keepsmalldif(array1,array2)
temp_array1 = array1;
temp_array2 = array2;
sliding_win=zeros(2,2);
for i=1:length(array1)
sliding_win(1,1) = sliding_win(1,2);
sliding_win(2,1) = sliding_win(2,2);
sliding_win(1,2) = array1(i);
sliding_win(2,2) = array2(i);
if ((sliding_win(1,1)==sliding_win(1,2))||(sliding_win(2,1)==sliding_win(2,2)))
temp1 = abs(sliding_win(1,1)-sliding_win(2,1));
temp2 = abs(sliding_win(1,2)-sliding_win(2,2));
if temp1>temp2
temp_array1(i-1)=0;
temp_array2(i-1)=0;
else
temp_array1(i)=0;
temp_array2(i)=0;
end
else
continue
end
end
temp_array1 = nonzeros(temp_array1)';
temp_array2 = nonzeros(temp_array2)';
end