MATLAB: How to generate an image from a matrix

imageimshow

The image would be 3 x 3 with the colors as shown below. The other can stay white.
Red Yellow
Green
Green Blue

Best Answer

Red = [255 0 0];
Yellow = [0 255 255];
Green = [0 0 255];
Blue = [0 255 0];
Im = uint8(255) * ones(3,3,3,'uint8');
Im(1,1,:) = Red;
Im(1,3,:) = Yellow;
and so on.
Related Question