MATLAB: Customizing colourmap for display

colormap

I have a matrix consisting of only the following values, 0, 1 and 2. I want to visualize the matrix by using the following colour code, green for 0, yellow for 1 and red for 2. How do I go about doing this? Any help will be appreciated.

Best Answer

Cmap = [0 1 0; 0 1 1; 1 0 0];
image(uint8(YourMatrix)) ;
colormap(Cmap) ;