<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265265</link>
    <title>MATLAB Central Newsreader - choosing a number at random</title>
    <description>Feed for thread: choosing a number at random</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Sun, 08 Nov 2009 01:45:04 -0500</pubDate>
      <title>choosing a number at random</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265265#692947</link>
      <author>Monica </author>
      <description>I need Matlab to choose a number between 1 and 10 at random, but I'm not sure how to go about doing this.</description>
    </item>
    <item>
      <pubDate>Sun, 08 Nov 2009 01:59:14 -0500</pubDate>
      <title>Re: choosing a number at random</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265265#692949</link>
      <author>Nasser M. Abbasi</author>
      <description>&lt;br&gt;
&quot;Monica &quot; &amp;lt;moh__krez@hotmail.com&amp;gt; wrote in message &lt;br&gt;
news:hd57r0$8c2$1@fred.mathworks.com...&lt;br&gt;
&amp;gt;I need Matlab to choose a number between 1 and 10 at random, but I'm not &lt;br&gt;
&amp;gt;sure how to go about doing this.&lt;br&gt;
&lt;br&gt;
If you want the random number to be drawn from uniform distribution, which I &lt;br&gt;
assume that is what you want, then do&lt;br&gt;
&lt;br&gt;
r = 10*rand&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
--Nasser</description>
    </item>
    <item>
      <pubDate>Sun, 08 Nov 2009 02:04:14 -0500</pubDate>
      <title>Re: choosing a number at random</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265265#692951</link>
      <author>Nasser M. Abbasi</author>
      <description>&lt;br&gt;
&quot;Nasser M. Abbasi&quot; &amp;lt;nma@12000.org&amp;gt; wrote in message &lt;br&gt;
news:VBpJm.18763$Wd1.2960@newsfe15.iad...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &quot;Monica &quot; &amp;lt;moh__krez@hotmail.com&amp;gt; wrote in message &lt;br&gt;
&amp;gt; news:hd57r0$8c2$1@fred.mathworks.com...&lt;br&gt;
&amp;gt;&amp;gt;I need Matlab to choose a number between 1 and 10 at random, but I'm not &lt;br&gt;
&amp;gt;&amp;gt;sure how to go about doing this.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; If you want the random number to be drawn from uniform distribution, which &lt;br&gt;
&amp;gt; I assume that is what you want, then do&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; r = 10*rand&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&lt;br&gt;
opps, you wanted it from 1 to 10, then do&lt;br&gt;
&lt;br&gt;
r = 1+9*rand&lt;br&gt;
&lt;br&gt;
(see help on rand)&lt;br&gt;
&lt;br&gt;
--Nasser </description>
    </item>
    <item>
      <pubDate>Sun, 08 Nov 2009 02:52:03 -0500</pubDate>
      <title>Re: choosing a number at random</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265265#692953</link>
      <author>ade77 </author>
      <description>&quot;Monica &quot; &amp;lt;moh__krez@hotmail.com&amp;gt; wrote in message &amp;lt;hd57r0$8c2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I need Matlab to choose a number between 1 and 10 at random, but I'm not sure how to go about doing this.&lt;br&gt;
&lt;br&gt;
you might also try randi(max), generates random number from 1:max.&lt;br&gt;
&lt;br&gt;
in your case randi(10)</description>
    </item>
    <item>
      <pubDate>Wed, 11 Nov 2009 15:18:55 -0500</pubDate>
      <title>Re: choosing a number at random</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265265#693889</link>
      <author>Peter Perkins</author>
      <description>Nasser M. Abbasi wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; opps, you wanted it from 1 to 10, then do&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; r = 1+9*rand&lt;br&gt;
&lt;br&gt;
Nasser, this is exactly the reason why we added RANDI a couple of releases ago: too easy to slip up.</description>
    </item>
    <item>
      <pubDate>Thu, 12 Nov 2009 00:22:02 -0500</pubDate>
      <title>Re: choosing a number at random</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265265#694053</link>
      <author>Greg Heath</author>
      <description>On Nov 11, 10:18&#160;am, Peter Perkins&lt;br&gt;
&amp;lt;Peter.Perk...@MathRemoveThisWorks.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Nasser M. Abbasi wrote:&lt;br&gt;
&amp;gt; &amp;gt; opps, you wanted it from 1 to 10, then do&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; r = 1+9*rand&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Nasser, this is exactly the reason why we added RANDI a couple of releases ago: too easy to slip up.&lt;br&gt;
&lt;br&gt;
Does rand ever generate 0 or 1?&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
    <item>
      <pubDate>Thu, 12 Nov 2009 00:30:18 -0500</pubDate>
      <title>Re: choosing a number at random</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/265265#694055</link>
      <author>Nathan</author>
      <description>On Nov 11, 4:22&#160;pm, Greg Heath &amp;lt;he...@alumni.brown.edu&amp;gt; wrote:&lt;br&gt;
&amp;gt; On Nov 11, 10:18&#160;am, Peter Perkins&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;lt;Peter.Perk...@MathRemoveThisWorks.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; Nasser M. Abbasi wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; opps, you wanted it from 1 to 10, then do&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; r = 1+9*rand&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Nasser, this is exactly the reason why we added RANDI a couple of releases ago: too easy to slip up.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Does rand ever generate 0 or 1?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Greg&lt;br&gt;
&lt;br&gt;
From the documentation:&lt;br&gt;
&quot;r = rand(n) returns an n-by-n matrix containing pseudorandom values&lt;br&gt;
drawn from the standard uniform distribution on the open interval&lt;br&gt;
(0,1).&quot;&lt;br&gt;
&lt;br&gt;
Meaning, 0 &amp;lt; r &amp;lt; 1&lt;br&gt;
&lt;br&gt;
-Nathan</description>
    </item>
  </channel>
</rss>

