MATLAB: Imagesc & plot matrix

correlationmatrixplot

Hello, actually i'm trying to plot a matrix. The values of this matrix are variable between -1 and 1 (i'm working on the correlation between different data). in figure:
this is a matrix 5×5 but to who has never seen the numerical matrix i think that it is difficult to understand. i want to know if exists a way to know for example what i'm correlating between the value 0.5 1.5, i mean i know what i'm correlating but i want that also the others watching this plot can understand it easy. another thing that i'ven't understood is what the numbers between 0.5 and 5.5 stay for.
pcolor can be used in this case?how?
thank you for the help

Best Answer

Salvatore, try this:
Im = [1.0000 0.7944 0.7361 0.8205 0.4192
0.7944 1.0000 0.8663 0.6780 0.3435
0.7361 0.8663 1.0000 0.7351 0.3311
0.8205 0.6780 0.7351 1.0000 0.3555
0.4192 0.3435 0.3311 0.3555 1.0000]
imagesc(Im)
cHandle = colorbar;
caxis([-1 1]) % This sets the visible range of colours
set(gca,'XTick',1:5,'YTick',1:5) % This sets the tick locations
You can also use different colours as seen in:
doc colormap
You can even supply your own colormap by building a matrix of N-by-3 values between 0 and 1.
The reason why your X/Y axes go from 0.5 to 5.5 is because every pixel has a size of 1 pixel. So the first pixel has a central location at [1,1]... but in order to show the whole pixel (with a width of 1 pixel), it has to start at location [0.5,05] and stretch to location [1.5,1.5]
A good explanation of this (with pictures) is at:
Doc > Image Processing Toolbox > Introduction