Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: generate long random vector by repeating 12 means and stds
Date: Thu, 15 Jan 2009 16:11:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <gknn6m$esn$1@fred.mathworks.com>
References: <gknl6u$p5t$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1232035862 15255 172.30.248.35 (15 Jan 2009 16:11:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 Jan 2009 16:11:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:511808

"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 Matlab-ish 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