Mercurial > hg > c4dm-chord-transcriptions
view evaluationtools/compareorderedsets.m @ 1:8973548174c1 tip
adding tools to repo
author | christopherh |
---|---|
date | Mon, 06 May 2013 14:43:47 +0100 |
parents | |
children |
line wrap: on
line source
function [match,success,errormessage] = compareorderedsets(set1,set2,cardinality) errormessage = ''; success = 1; match = 0; if nargin<3 cardinality = 6; end % check to see if sets are same type if strcmp(class(set1),class(set2)) % check whether dealing with strings, cell arrays of chars or arrays of ints if ischar(set1) % compare strings if strcmp(set1,set2) match = 1; else match = 0; end end if iscell(set1) % compare cell arrays of characters % fill blank spaces so that cardinalities match while length(set1)<cardinality set1 = [set1, '-']; end while length(set2)<cardinality set2 = [set2, '-']; end for i = 1:cardinality if strcmp(set1{i},set2{i}) match = 1; else match = 0; break; end end end if isnumeric(set1) && isnumeric(set2) % compare integers % fill blank spaces so that cardinalities match while length(set1)<cardinality set1 = [set1,-1]; end while length(set2)<cardinality set2 = [set2,-1]; end for i = 1:cardinality if set1(i)==set2(i) match = 1; else match = 0; break; end end end else % trying to compare mixed data types errormessage = 'Error in compareorderedsets: trying to compare mixed data types'; success= 0; end