Dawn@4: Dawn@4: function [ groupStats, orderedGroups ] = processKMeansResults( ID, idx, ... Dawn@4: groupingCriteria, masterFileOutputID, titleName, DEBUG ) Dawn@4: Dawn@4: if( length( idx ) ~= length( groupingCriteria ) ) Dawn@4: disp('EEEK!'); Dawn@4: pause; Dawn@4: end Dawn@4: Dawn@4: groupIDs = ''; Dawn@4: groupStr = ''; Dawn@4: for( i = 1 : length( idx )) Dawn@4: % fprintf( fileOutputID, '%s \t %d \n', groupingCriteria(i), idx(i) ); Dawn@4: gID = [ groupingCriteria(i) num2str( idx(i) )]; Dawn@4: groupIDs = [ groupIDs ; gID ]; Dawn@4: groupStr = [ groupStr gID ]; Dawn@4: end Dawn@4: Dawn@4: % ------------- work out the confusion matrix ------------------------- Dawn@4: Dawn@4: groups = unique( groupIDs, 'rows' ); Dawn@4: noOfGroups = length( groups ); Dawn@4: orderedGroups = sort(cellstr(groups)); Dawn@4: groupStats = []; Dawn@4: for( i = 1 : noOfGroups ) Dawn@4: groupStats(i) = ((length( strfind( groupStr, char(orderedGroups(i)))))/length( idx ) ) * 100; Dawn@4: end Dawn@4: Dawn@4: if(DEBUG == 1) Dawn@4: figure(1); Dawn@4: bar( groupStats ); Dawn@4: set( gca, 'XTickLabel', orderedGroups ); Dawn@4: title([ titleName ' ' ID]); Dawn@4: end Dawn@4: end