MATLAB: How to generate Zero mean and unit variance

meanpseudo randomrandunit variance

I'm not sure how to generate 1024 samples of pseudo random numbers with zero mean and unit variance using rand and to verify the results with mean, std, and hist.

Best Answer

If you want a uniform distribution do this:
n = 1024;
x = sqrt(3)*(2*rand(n,1)-1);
The random variable x will have a statistical mean of 0 and variance of 1. Of course any given n-element sample will deviate from these. These are only the statistically expected values.