Try this:
a=[1 2 3 4 5; 6 7 8 9 10];
a=a./max(a(:));
rgbImage(:,:,1)=a;
rgbImage(:,:,2)=a;
rgbImage(:,:,3)=a;
subplot(1, 3, 1);
imshow(rgbImage);
% Create mask
mask = logical([1 0 0 0 0;1 1 0 0 0]);
subplot(1, 3, 2);
imshow(mask);
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
% Apply mask to make it 1 in the red channel and 0 in the green and blue channels.
redChannel(mask) = 1;
greenChannel(mask) = 0;
blueChannel(mask) = 0;
% Recombine separate color channels into a single, true color RGB image.
rgbImage = cat(3, redChannel, greenChannel, blueChannel);
subplot(1, 3, 3);
imshow(rgbImage);