annotate 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
rev   line source
wolffd@0 1 function i = intersect(a,b,thr)
wolffd@0 2
wolffd@0 3 if nargin<3
wolffd@0 4 thr = .01;
wolffd@0 5 end
wolffd@0 6
wolffd@0 7 va = get(a,'PeakVal');
wolffd@0 8 pa = get(a,'PeakPos');
wolffd@0 9 ma = get(a,'PeakMode');
wolffd@0 10 if isa(a,'mirscalar')
wolffd@0 11 xa = get(a,'FramePos');
wolffd@0 12 else
wolffd@0 13 xa = get(a,'Pos');
wolffd@0 14 end
wolffd@0 15 vb = get(b,'PeakVal');
wolffd@0 16 pb = get(b,'PeakPos');
wolffd@0 17 mb = get(b,'PeakMode');
wolffd@0 18 if isa(b,'mirscalar')
wolffd@0 19 xb = get(b,'FramePos');
wolffd@0 20 else
wolffd@0 21 xb = get(b,'Pos');
wolffd@0 22 end
wolffd@0 23
wolffd@0 24 for j = 1:length(va)
wolffd@0 25 for k = 1:length(va{j})
wolffd@0 26 [nl nc np] = size(va{j}{k});
wolffd@0 27 for c = 1:nc
wolffd@0 28 for p = 1:np
wolffd@0 29 [pacp,ix] = sort(pa{j}{k}{1,c,p});
wolffd@0 30 vacp = va{j}{k}{1,c,p}(ix);
wolffd@0 31 macp = ma{j}{k}{1,c,p}(ix);
wolffd@0 32 [pbcp,ix] = sort(pb{j}{k}{1,c,p});
wolffd@0 33 xajk = xa{j}{k};
wolffd@0 34 xbjk = xb{j}{k};
wolffd@0 35 if isa(a,'mirscalar')
wolffd@0 36 xajk = mean(xajk);
wolffd@0 37 end
wolffd@0 38 if isa(b,'mirscalar')
wolffd@0 39 xbjk = mean(xbjk);
wolffd@0 40 end
wolffd@0 41 ia = 1;
wolffd@0 42 ib = 1;
wolffd@0 43 ii = 1;
wolffd@0 44 while ia <= length(pacp) && ib <= length(pbcp)
wolffd@0 45 if abs(xajk(pacp(ia))-xbjk(pbcp(ib)))<thr
wolffd@0 46 picp(ii) = pacp(ia);
wolffd@0 47 vicp(ii) = vacp(ia);
wolffd@0 48 micp(ii) = macp(ia);
wolffd@0 49 ia = ia+1;
wolffd@0 50 ib = ib+1;
wolffd@0 51 ii = ii+1;
wolffd@0 52 elseif xajk(pacp(ia))<xbjk(pbcp(ib))
wolffd@0 53 ia = ia+1;
wolffd@0 54 else
wolffd@0 55 ib = ib+1;
wolffd@0 56 end
wolffd@0 57 end
wolffd@0 58 pa{j}{k}{1,c,p} = picp;
wolffd@0 59 va{j}{k}{1,c,p} = vicp;
wolffd@0 60 ma{j}{k}{1,c,p} = micp;
wolffd@0 61 end
wolffd@0 62 end
wolffd@0 63 end
wolffd@0 64 end
wolffd@0 65
wolffd@0 66 i = set(a,'PeakPos',pa,'PeakVal',va,'PeakMode',ma);