MATLAB: Generate a random data with fix mean

functionmatrix

I have a matrix with 360 elements and I need to expand it to 3600 elements with the same mean and standard deviation.

Best Answer

You don't say the size of your matrix, you just tell us the number of elements. You also do not give us any information about the distribution -- is it Gaussian?
Xstart = randn(360,1);
meanX = mean(Xstart);
stdX = std(Xstart);
Xend = [Xstart ; stdX*randn(3600-360,1)+meanX];
Related Question