Hi Sheetal:
Red, Green, and Blue channels are read from the first, second, and third 'pages' of a matrix, respectively. Thus, at the very least, you need an M * N * 3 matrix. You can include a fourth 'page' if you want your image to contain an alpha channel.
Here is an example of simple square-wave grating that alternates between red and blue bars. This should get the main idea across:
mata = 255*ones(100,10);
matb = zeros(100,10);
red = cat(3, mata, matb, matb);
blue = cat(3, matb, matb, mata);
rb_sqwv = repmat([red, blue], 5);
img = imshow(rb_sqwv)
Cheers,
Ray
