# MATLAB: RGB image of size 500 x 500 pixels to a single array of size 250000.

digital communicationimage processing

Q. "Take a colored image of yourself consisting of RGB components of size 500×500 pixels. Read this image in Matlab and you will get the three channel components. Convert these three channels to a single array of size 250000"
What I am doing in this situation is, first i read the image than i split it into different R, G, B channel and then I m stuck in making the single array from those R, G, B channels.
My code is pasted below:
% Read an image (500 x 500 px) in MATLAB
% Extract the individial R, G and B Channel
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
z = zeros(size(rgbImage), class(rgbImage));
redImage = z; redImage(:,:,1) = redChannel;
greenImage = z; greenImage(:,:,2) = greenChannel;
blueImage = z; blueImage(:,:,3) = blueChannel;
subplot(2,2,1); image(rgbImage);
subplot(2,2,2); image(redImage);
subplot(2,2,3); image(greenImage);
subplot(2,2,4); image(blueImage);
% Convert three channels to a single array of size 250000
Need help !!