christopherh@1: christopherh@1: function [match,success,errormessage] = compareunorderedsets(set1,set2,cardinality) christopherh@1: christopherh@1: christopherh@1: if nargin<3 christopherh@1: cardinality = 6; christopherh@1: end christopherh@1: christopherh@1: christopherh@1: christopherh@1: errormessage = ''; christopherh@1: success = 1; christopherh@1: match = 0; christopherh@1: christopherh@1: christopherh@1: christopherh@1: if strcmp(class(set1),class(set2)) christopherh@1: christopherh@1: christopherh@1: % make sure that the sets don't contain duplicate objects christopherh@1: X = unique(set1); christopherh@1: Y = unique(set2); christopherh@1: christopherh@1: christopherh@1: u = length(intersect(X,Y)); christopherh@1: christopherh@1: m = min(cardinality,max(length(X),length(Y))); christopherh@1: christopherh@1: if u >= m christopherh@1: christopherh@1: match = 1; christopherh@1: christopherh@1: else christopherh@1: christopherh@1: match = 0; christopherh@1: christopherh@1: end christopherh@1: else christopherh@1: success = 0; christopherh@1: errormessage = 'Error in compareunorderedsets: trying to compare mixed data types'; christopherh@1: end