Mercurial > hg > mauch-mirex-2010
annotate _FullBNT/KPMtools/approx_unique.m @ 9:4ea6619cb3f5 tip
removed log files
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:55:11 +0100 |
parents | b5b38998ef3b |
children |
rev | line source |
---|---|
matthiasm@8 | 1 function [B, keep] = approx_unique(A, thresh, flag) |
matthiasm@8 | 2 % APPROX_UNIQUE Return elements of A that differ from the rest by less than thresh |
matthiasm@8 | 3 % B = approx_unique(A, thresh) |
matthiasm@8 | 4 % B = approx_unique(A, thresh, 'rows') |
matthiasm@8 | 5 |
matthiasm@8 | 6 keep = []; |
matthiasm@8 | 7 |
matthiasm@8 | 8 if nargin < 3 | isempty(flag) |
matthiasm@8 | 9 A = sort(A) |
matthiasm@8 | 10 B = A(1); |
matthiasm@8 | 11 for i=2:length(A) |
matthiasm@8 | 12 if ~approxeq(A(i), A(i-1), thresh) |
matthiasm@8 | 13 B = [B A(i)]; |
matthiasm@8 | 14 keep = [keep i]; |
matthiasm@8 | 15 end |
matthiasm@8 | 16 end |
matthiasm@8 | 17 else |
matthiasm@8 | 18 % A = sortrows(A); |
matthiasm@8 | 19 % B = A(1,:); |
matthiasm@8 | 20 % for i=2:size(A,1) |
matthiasm@8 | 21 % if ~approxeq(A(i,:), A(i-1,:), thresh) |
matthiasm@8 | 22 % B = [B; A(i,:)]; |
matthiasm@8 | 23 % keep = [keep i]; |
matthiasm@8 | 24 % end |
matthiasm@8 | 25 % end |
matthiasm@8 | 26 B = []; |
matthiasm@8 | 27 for i=1:size(A,1) |
matthiasm@8 | 28 duplicate = 0; |
matthiasm@8 | 29 for j=i+1:size(A,1) |
matthiasm@8 | 30 if approxeq(A(i,:), A(j,:), thresh) |
matthiasm@8 | 31 duplicate = 1; |
matthiasm@8 | 32 break; |
matthiasm@8 | 33 end |
matthiasm@8 | 34 end |
matthiasm@8 | 35 if ~duplicate |
matthiasm@8 | 36 B = [B; A(i,:)]; |
matthiasm@8 | 37 keep = [keep i]; |
matthiasm@8 | 38 end |
matthiasm@8 | 39 end |
matthiasm@8 | 40 end |
matthiasm@8 | 41 |