MATLAB: Concatenate the produced arrays from a for loop

for loop concatenate mean standard deviation column sequence images

I am trying to calculate the mean and standard deviation of the R,G,B channels of 50 image files in sequence. I would like to write out the mean of these into a single column vector per color. This would result in 3 50×1 column vectors – one each for R, G, B. I am able to calculate the means, but they are being output separately. Thanks
for j = 1:50
fname = sprintf('test (%d).bmp',j);
image4d = imread(fname);
Mean = squeeze(mean(image4d, [1 2]));
MeanR = Mean(1,:)
MeanG = Mean(2,:)
MeanB = Mean(3,:)
end
My output looks like:
MeanR =
25.1629
MeanG =
3.1821
MeanB =
0
MeanR =
31.6650
MeanG =
3.6093
MeanB =
0
.
.
For all 50 images.

Best Answer

Mean=nan(50,3);
for j = 1:50
fname = sprintf('test (%d).bmp',j);
image4d = imread(fname);
Mean(j,:) = mean( image4d , [1 2]) ;
end
MeanR=Mean(:,1);
MeanG=Mean(:,2);
MeanB=Mean(:,3);