Mercurial > hg > camir-aes2014
comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/@mirdata/intersect.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function i = intersect(a,b,thr) | |
2 | |
3 if nargin<3 | |
4 thr = .01; | |
5 end | |
6 | |
7 va = get(a,'PeakVal'); | |
8 pa = get(a,'PeakPos'); | |
9 ma = get(a,'PeakMode'); | |
10 if isa(a,'mirscalar') | |
11 xa = get(a,'FramePos'); | |
12 else | |
13 xa = get(a,'Pos'); | |
14 end | |
15 vb = get(b,'PeakVal'); | |
16 pb = get(b,'PeakPos'); | |
17 mb = get(b,'PeakMode'); | |
18 if isa(b,'mirscalar') | |
19 xb = get(b,'FramePos'); | |
20 else | |
21 xb = get(b,'Pos'); | |
22 end | |
23 | |
24 for j = 1:length(va) | |
25 for k = 1:length(va{j}) | |
26 [nl nc np] = size(va{j}{k}); | |
27 for c = 1:nc | |
28 for p = 1:np | |
29 [pacp,ix] = sort(pa{j}{k}{1,c,p}); | |
30 vacp = va{j}{k}{1,c,p}(ix); | |
31 macp = ma{j}{k}{1,c,p}(ix); | |
32 [pbcp,ix] = sort(pb{j}{k}{1,c,p}); | |
33 xajk = xa{j}{k}; | |
34 xbjk = xb{j}{k}; | |
35 if isa(a,'mirscalar') | |
36 xajk = mean(xajk); | |
37 end | |
38 if isa(b,'mirscalar') | |
39 xbjk = mean(xbjk); | |
40 end | |
41 ia = 1; | |
42 ib = 1; | |
43 ii = 1; | |
44 while ia <= length(pacp) && ib <= length(pbcp) | |
45 if abs(xajk(pacp(ia))-xbjk(pbcp(ib)))<thr | |
46 picp(ii) = pacp(ia); | |
47 vicp(ii) = vacp(ia); | |
48 micp(ii) = macp(ia); | |
49 ia = ia+1; | |
50 ib = ib+1; | |
51 ii = ii+1; | |
52 elseif xajk(pacp(ia))<xbjk(pbcp(ib)) | |
53 ia = ia+1; | |
54 else | |
55 ib = ib+1; | |
56 end | |
57 end | |
58 pa{j}{k}{1,c,p} = picp; | |
59 va{j}{k}{1,c,p} = vicp; | |
60 ma{j}{k}{1,c,p} = micp; | |
61 end | |
62 end | |
63 end | |
64 end | |
65 | |
66 i = set(a,'PeakPos',pa,'PeakVal',va,'PeakMode',ma); |