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$>
References: <jfhofu$l8u$>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1327327749 1044 (23 Jan 2012 14:09:09 GMT)
NNTP-Posting-Date: Mon, 23 Jan 2012 14:09:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: comp.soft-sys.matlab:755464

"Kevin Ellis" wrote in message <jfhofu$l8u$>...
> 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: