0001 function [mask_mtx, unique_vals] = make_mask_mtx(data_vect)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 if size(data_vect,2) > 1
0015 nrows = size(data_vect,1);
0016 if iscell(data_vect)
0017 tmpdata = data_vect;
0018 nvars = size(tmpdata,2);
0019 numCombos = 0;
0020 while size(tmpdata,1)
0021 numCombos = numCombos+1;
0022 if mod(numCombos,20) == 0
0023 fprintf('%d', numCombos);
0024 else
0025 fprintf('.');
0026 end
0027
0028
0029 currCombo = tmpdata(1,:);
0030
0031
0032 [unique_vals(numCombos,1:nvars)] = deal(currCombo);
0033
0034 mask_mtx(:,numCombos) = all(strcmp(data_vect,repmat(currCombo,nrows,1)),2);
0035
0036 currComboMask = all(strcmp(tmpdata,repmat(currCombo,size(tmpdata,1),1)),2);
0037
0038 tmpdata(currComboMask,:) = [];
0039 end
0040
0041 fprintf('\n');
0042 return
0043 else
0044 unique_vals = unique(data_vect,'rows');
0045 end
0046 else
0047 unique_vals = unique(data_vect);
0048 end
0049
0050
0051 if isnumeric(unique_vals)
0052 unique_vals(isnan(unique_vals)) = [];
0053 end
0054
0055 nvals = length(unique_vals);
0056 mask_mtx = false(size(data_vect,1),nvals);
0057
0058 fprintf('Calculating masks for %d unique values\n', nvals);
0059 for ival = 1:nvals
0060 if mod(ival,20) == 0
0061 fprintf('%d', ival);
0062 else
0063 fprintf('.');
0064 end
0065 if isnumeric(unique_vals)
0066 mask_mtx(:,ival) = data_vect == unique_vals(ival);
0067 elseif iscell(unique_vals(ival)) && ischar(unique_vals{ival})
0068 mask_mtx(:,ival) = strcmp(unique_vals{ival}, data_vect);
0069 else
0070 mask_mtx(:,ival) = ismember(data_vect, unique_vals(ival));
0071 end
0072 end
0073 fprintf('\n');
0074
0075 return
0076