confmat = C;labels = {'0', '1', '2', '3', '11' };numlabels = size(confmat, 1); % number of labels
confpercent = 100*confmat./repmat(sum(confmat, 1),numlabels,1);imagesc(confpercent);Mycolors=[0 0.7 0.4; 1 0.9 0.9 ]colormap(flipud(Mycolors));textStrings = num2str([confpercent(:)], '%.1f%%\n');textStrings = strtrim(cellstr(textStrings)); [x,y] = meshgrid(1:numlabels);hStrings = text(x(:),y(:),textStrings(:), ... 'HorizontalAlignment','center');midValue = mean(get(gca,'CLim'));textColors = repmat(confpercent(:) > midValue,1,3);set(hStrings,{'Color'},num2cell(textColors,2));set(gca,'XTick',1:numlabels,... 'XTickLabel',labels,... 'YTick',1:numlabels,... 'YTickLabel',labels,... 'TickLength',[0 0]);
From the above code I got the next picture
How it is possible to add horizontal lines to get a CM like the next :
Best Answer