-
Notifications
You must be signed in to change notification settings - Fork 0
/
matchAndExcludePeaks.m
42 lines (38 loc) · 1.15 KB
/
matchAndExcludePeaks.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
function [matchedPeaks1, matchedPeaks2] = matchAndExcludePeaks(peaks1, peaks2)
len1 = length(peaks1);
len2 = length(peaks2);
matchedPeaks1 = [];
matchedPeaks2 = [];
for i=1:len1
for j=1:len2
dist(i,j) = abs(peaks1(i) - peaks2(j));
end
end
if len1>=len2
%matchedPeaks2 = peaks2 ;
count = 1;
for i=1:len2
if min(dist(:,i))<=5
[row, ~] = find(dist(:,i) == min(dist(:,i)));
matchedPeaks1(count) = peaks1(row(1));
matchedPeaks2(count) = peaks2(i);
count = count + 1 ;
else
continue
end
end
else
%matchedPeaks1 = peaks1 ;
count = 1;
for i=1:len1
if min(dist(i,:))<=5
[~, column] = find(dist(i,:) == min(dist(i,:)));
matchedPeaks1(count) = peaks1(i);
matchedPeaks2(count) = peaks2(column(1));
count = count + 1 ;
else
continue
end
end
end
end