MATLAB: How to display a matrix as a image

imageimage analysismatricesmatrix

my matrix of dimension 120×50 has elements ranging from -1 to 200 . I want to display this matrix as a image in which the matrix cells containing -1 should be displayed as black and 0 should be displayed as white and all positive numbers by red(or green) How to do it ?

Best Answer

A=randi([-1 200],120,50)
map=[0 0 0;1 1 1;1 0 0];
idx1=A==-1
idx0=A==0
idx2=A>0
A(idx1)=1
A(idx0)=2
A(idx2)=3
image(A)
colormap(map)