Search code examples
matlabconfusion-matrix

Confusion matrix image in matlab


I'm trying to make a confusion matrix for some classification problem. So far, I've managed to make a 10 by 10 matrix that stores the accuracy of my estimation for classification problem.

Now I want to make a 10 by 10 square image(?) that has a darker color when the number in that location of the matrix has a higher number. (Ranges from 0 to 100)

I've never done graphics with Matlab before. Any help would be greatly appreciated.

Thanks.


Solution

  • I would use image. For example:

    img = 100*rand(4,4);  % Your image
    img = img./100*64;  % The `image` function works on scale from 0->64
    image(img); % or `image(img')` depending on how you want the axis
    colormap('grey'); % For grey scale images
    axis equal;       % For square pixels
    

    Or for inverted colours you can change the one line to:

    img = 64-img./100*64;