function drawConflictMatrix(s,M,str)
%draw the conflict matrix M with imagesc in gray

figure;
n = size(M,1);
mat = M;           %# A n-by-n matrix
imagesc(mat);            %# Create a colored plot of the matrix values
colormap(flipud(gray));  %# Change the colormap to gray (so higher values are
                         %#   black and lower values are white)

textStrings = num2str(mat(:),'%d');  %# Create strings from the matrix values
textStrings = strtrim(cellstr(textStrings));  %# Remove any space padding
[x,y] = meshgrid(1:n);   %# Create x and y coordinates for the strings
hStrings = text(x(:),y(:),textStrings(:),...      %# Plot the strings
                'HorizontalAlignment','center');

for i=1:n
    text(i,s(i),num2str(mat(s(i),i),'%d'),...      %# Plot the strings
                'HorizontalAlignment','center','Color','red');
end
            
midValue = mean(get(gca,'CLim'));  %# Get the middle value of the color range
textColors = repmat(mat(:) > midValue,1,3);  %# Choose white or black for the
                                             %#   text color of the strings so
                                             %#   they can be easily seen over
                                             %#   the background color
set(hStrings,{'Color'},num2cell(textColors,2));  %# Change the text colors

set(gca,'XTick',1:n,...                         %# Change the axes tick marks
        'YTick',1:n,...
        'TickLength',[0 0],...
        'Title',text('String',str));



%hold on
%imagesc(M);
%colormap(gray);
%colorbar;
%hold off
