annotate evaluationtools/compareunorderedsets.m @ 1:8973548174c1 tip

adding tools to repo
author christopherh
date Mon, 06 May 2013 14:43:47 +0100
parents
children
rev   line source
christopherh@1 1
christopherh@1 2 function [match,success,errormessage] = compareunorderedsets(set1,set2,cardinality)
christopherh@1 3
christopherh@1 4
christopherh@1 5 if nargin<3
christopherh@1 6 cardinality = 6;
christopherh@1 7 end
christopherh@1 8
christopherh@1 9
christopherh@1 10
christopherh@1 11 errormessage = '';
christopherh@1 12 success = 1;
christopherh@1 13 match = 0;
christopherh@1 14
christopherh@1 15
christopherh@1 16
christopherh@1 17 if strcmp(class(set1),class(set2))
christopherh@1 18
christopherh@1 19
christopherh@1 20 % make sure that the sets don't contain duplicate objects
christopherh@1 21 X = unique(set1);
christopherh@1 22 Y = unique(set2);
christopherh@1 23
christopherh@1 24
christopherh@1 25 u = length(intersect(X,Y));
christopherh@1 26
christopherh@1 27 m = min(cardinality,max(length(X),length(Y)));
christopherh@1 28
christopherh@1 29 if u >= m
christopherh@1 30
christopherh@1 31 match = 1;
christopherh@1 32
christopherh@1 33 else
christopherh@1 34
christopherh@1 35 match = 0;
christopherh@1 36
christopherh@1 37 end
christopherh@1 38 else
christopherh@1 39 success = 0;
christopherh@1 40 errormessage = 'Error in compareunorderedsets: trying to compare mixed data types';
christopherh@1 41 end