"Kirk" <kwythers.nospam@umn.edu> wrote in message <gknl6u$p5t$1@fred.mathworks.com>...
> I need to generate 1200 random elements from 12 mean values and 12 standard deviations.
>
> I have created the vectors:
> y_mu = [7.22,3.67,2.40,11.25,19.11,23.89,26.73,25.26,19.61,12.78,2.38,4.82]
> y_sigma = [3.04,2.82,2.48,2.73,2.26,1.78,1.64,1.77,1.79,2.06,2.46,2.63]
>
> I then used normrnd to generate a new vector of 12 random elments:
> y_rand = normrnd(y_mu,y_sigma,1,12);
>
> My trouble is that I need to do this 100 times, generating a vector with a dimension of 1,1200 every 12 elements represent a new call to the function normrand generating 12 new random elements based on the 12 y_mu and y_sigma.
>
> Should this be done in a loop? or is there a more elegant Matlabish approach?
>
You can do it with one call to 'normrnd' if you do a 'repmat' on 'y_mu' and 'y_sigma'.
y_rand = normrnd(repmat(y_mu,1,100),repmat(y_sigma,1,100));
Note: This advice is based on reading the documentation. I haven't actually used 'normrnd' myself.
Roger Stafford
