Matlab stores the image as a 3-dimensional array. The first two dimensions correspond to the numbers on the axis of the above picture. Each pixel is represented by three entries in the third dimension of the image. Each of the three layers represents the intensity of red, green, and blue in the array of pixels. We can extract out the independent red-green-blue components of the image by:
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
For example original image is:
If you display red green and blue channels you get these grayscaled images:

If you concatenate one of these channels with two black matrices (zero matrices) you get colored image. Let us concatenate each channel with black image matrices for remaining channels:
blackImage = uint8(zeros(rows, columns));
newRedChannel = cat(3, redChannel, blackImage, blackImage);
newGreenChannel = cat(3, blackImage, greenChannel, blackImage);
newBlueChannel = cat(3, blackImage, blackImage, blueChannel);
It outputs the following images:

Why does it work this way? Why individual channels for each color have to be concatenated with zero matrices (black images) for remaining channels in order for it be be colored when displaying? And why individual channels of colors are actually just grayscaled images if displayed individually?