Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Help with randn function
Date: Mon, 23 Jan 2012 14:09:09 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 15
Message-ID: <jfjpm5$10k$1@newscl01ah.mathworks.com>
References: <jfhofu$l8u$1@newscl01ah.mathworks.com>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1327327749 1044 172.30.248.46 (23 Jan 2012 14:09:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 23 Jan 2012 14:09:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:755464

"Kevin Ellis" wrote in message <jfhofu$l8u$1@newscl01ah.mathworks.com>...
> Hello,
> 
> I need to generate an array with numbers within the range [-1:1]. I would like to use the built in function "randn" to build the array. For example, in my M-File I write
> 
> A = randn(1,20);
> 
> However, some elements of the Array A are not within the range [-1:1]. I have tried to use while loops to check each element and try to keep it within the range, but this isn't working very well.
> 
> Is there a way to designate a range for the built in function "randn"?

This function will help:
http://www.mathworks.com/matlabcentral/fileexchange/23832-truncated-gaussian

Bruno