0001 function [non_unique_mask, non_unique_vals] = check_unique_rows(mtx,verbose)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 if nargin < 2
0014 verbose = 1;
0015 end
0016
0017 if ~any(strcmp({'nominal','ordinal'}, class(mtx)))
0018 error('Class of input data must be nominal or ordinal')
0019 end
0020
0021 nrows = size(mtx,1);
0022
0023 non_unique_mask = false(nrows,1);
0024 non_unique_vals = [];
0025
0026 uniqueRows = unique(mtx,'rows');
0027 numNonUnique = nrows - size(uniqueRows,1);
0028 if numNonUnique
0029 if verbose
0030 fprintf('Found %d non-unique rows%s\n',numNonUnique);
0031 end
0032
0033 [~,idxs] = ismember(mtx,uniqueRows,'rows');
0034
0035
0036 t = tabulate(idxs);
0037
0038
0039 non_unique_vals = uniqueRows(t(:,2)>1,:);
0040 if verbose
0041 non_unique_vals
0042 end
0043 non_unique_mask = ismember(mtx,non_unique_vals,'rows');
0044 end
0045
0046 end