<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308</link>
    <title>MATLAB Central Newsreader - randperm</title>
    <description>Feed for thread: randperm</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>Sat, 26 Jul 2008 19:35:03 -0400</pubDate>
      <title>randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445632</link>
      <author>ching l</author>
      <description>a= randperm(6)&lt;br&gt;
&lt;br&gt;
I want the &quot;a&quot; to have different number each time, between &lt;br&gt;
1 to 6.  However, by using randperm, it called out all the 6&lt;br&gt;
random numbers at a time, which become a= 1 4 6 2 3 5&lt;br&gt;
&lt;br&gt;
How do I have different random &quot;a&quot; each time?&lt;br&gt;
&lt;br&gt;
for example, &lt;br&gt;
&lt;br&gt;
a= 1&lt;br&gt;
&lt;br&gt;
a= 3&lt;br&gt;
&lt;br&gt;
a= 5&lt;br&gt;
&lt;br&gt;
instead of a= 1 4 2 6 3 5</description>
    </item>
    <item>
      <pubDate>Sat, 26 Jul 2008 20:14:02 -0400</pubDate>
      <title>Re: randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445634</link>
      <author>matt dash</author>
      <description>&quot;ching l&quot; &amp;lt;chinglnc@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g6fu97$7ru$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; a= randperm(6)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I want the &quot;a&quot; to have different number each time, between &lt;br&gt;
&amp;gt; 1 to 6.  However, by using randperm, it called out all the 6&lt;br&gt;
&amp;gt; random numbers at a time, which become a= 1 4 6 2 3 5&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; How do I have different random &quot;a&quot; each time?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; for example, &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a= 1&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a= 3&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a= 5&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; instead of a= 1 4 2 6 3 5&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
a=ceil(6*rand)</description>
    </item>
    <item>
      <pubDate>Sat, 26 Jul 2008 20:33:07 -0400</pubDate>
      <title>Re: randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445635</link>
      <author>ching l</author>
      <description>&quot;matt dash&quot; &amp;lt;n.a@mail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g6g0ia$vp$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;ching l&quot; &amp;lt;chinglnc@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g6fu97$7ru$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; a= randperm(6)&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I want the &quot;a&quot; to have different number each time, between &lt;br&gt;
&amp;gt; &amp;gt; 1 to 6.  However, by using randperm, it called out all the 6&lt;br&gt;
&amp;gt; &amp;gt; random numbers at a time, which become a= 1 4 6 2 3 5&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; How do I have different random &quot;a&quot; each time?&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; for example, &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; a= 1&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; a= 3&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; a= 5&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; instead of a= 1 4 2 6 3 5&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a=ceil(6*rand)&lt;br&gt;
&lt;br&gt;
but it's going to repeat some time....&lt;br&gt;
&lt;br&gt;
I don't want it to repeat, I want to have random number from&lt;br&gt;
1 to 6, for six time, and no repeat number.&lt;br&gt;
&lt;br&gt;
is that possible?</description>
    </item>
    <item>
      <pubDate>Sun, 27 Jul 2008 09:04:09 -0400</pubDate>
      <title>Re: randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445682</link>
      <author>Bruno Luong</author>
      <description>&quot;ching l&quot; &amp;lt;chinglnc@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g6g1m3$cec$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I want to have random number from&lt;br&gt;
&amp;gt; 1 to 6, for six time, and no repeat number.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
And what do you get with one call of randperm(6)? Can you&lt;br&gt;
try to describe it in words and see how it fits with what&lt;br&gt;
you wrote above.&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Sun, 27 Jul 2008 12:40:39 -0400</pubDate>
      <title>Re: randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445696</link>
      <author>ching l</author>
      <description>&quot;Bruno Luong&quot; &amp;lt;b.luong@fogale.findmycountry&amp;gt; wrote in&lt;br&gt;
message &amp;lt;g6hdm9$j18$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;ching l&quot; &amp;lt;chinglnc@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g6g1m3$cec$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; I want to have random number from&lt;br&gt;
&amp;gt; &amp;gt; 1 to 6, for six time, and no repeat number.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; And what do you get with one call of randperm(6)? Can you&lt;br&gt;
&amp;gt; try to describe it in words and see how it fits with what&lt;br&gt;
&amp;gt; you wrote above.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Bruno&lt;br&gt;
&lt;br&gt;
I have six audio files, &lt;br&gt;
&lt;br&gt;
sample{1}= wavread('audio1.wav');&lt;br&gt;
sample{2}= wavread('audio2.wav');&lt;br&gt;
sample{3}= wavread('audio3.wav');&lt;br&gt;
sample{4}= wavread('audio4.wav');&lt;br&gt;
sample{5}= wavread('audio5.wav');&lt;br&gt;
sample{6}= wavread('audio6.wav');&lt;br&gt;
&lt;br&gt;
wavplay= sample(round{random number});&lt;br&gt;
&lt;br&gt;
so, when I call the wavplay everytime, it should play&lt;br&gt;
different audio each time. &lt;br&gt;
&lt;br&gt;
but randperm(6) = (3 4 5 1 2 6);&lt;br&gt;
&lt;br&gt;
possible to work around with that?</description>
    </item>
    <item>
      <pubDate>Sun, 27 Jul 2008 12:56:07 -0400</pubDate>
      <title>Re: randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445698</link>
      <author>Bruno Luong</author>
      <description>&quot;ching l&quot; &amp;lt;chinglnc@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g6hqc7$gck$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; so, when I call the wavplay everytime, it should play&lt;br&gt;
&amp;gt; different audio each time. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; but randperm(6) = (3 4 5 1 2 6);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; possible to work around with that?&lt;br&gt;
&lt;br&gt;
Work around of what problem ?&lt;br&gt;
Just playing track #3, then 4, 5, 1, 2, and then 6 according&lt;br&gt;
to randperm result. Wasn't that a six number randomly chosen&lt;br&gt;
and never repeated? Isn't that what you asked for???&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Sun, 27 Jul 2008 13:58:02 -0400</pubDate>
      <title>Re: randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445708</link>
      <author>ching l</author>
      <description>&quot;Bruno Luong&quot; &amp;lt;b.luong@fogale.findmycountry&amp;gt; wrote in&lt;br&gt;
message &amp;lt;g6hr97$sq6$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;ching l&quot; &amp;lt;chinglnc@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g6hqc7$gck$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; so, when I call the wavplay everytime, it should play&lt;br&gt;
&amp;gt; &amp;gt; different audio each time. &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; but randperm(6) = (3 4 5 1 2 6);&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; possible to work around with that?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Work around of what problem ?&lt;br&gt;
&amp;gt; Just playing track #3, then 4, 5, 1, 2, and then 6 according&lt;br&gt;
&amp;gt; to randperm result. Wasn't that a six number randomly chosen&lt;br&gt;
&amp;gt; and never repeated? Isn't that what you asked for???&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Bruno&lt;br&gt;
&lt;br&gt;
The error- Too many input arguments.&lt;br&gt;
&lt;br&gt;
wavplay (sample{randperm(6)});&lt;br&gt;
&lt;br&gt;
because it's using six random numbers at a time.&lt;br&gt;
I only want it to play one random number at a time.&lt;br&gt;
That means, whenever I call the wavplay function, it will&lt;br&gt;
randomly choose from 1 to 6, and when I call that function&lt;br&gt;
again, it will choose from 1 to 6, but not the same number&lt;br&gt;
that used before that.</description>
    </item>
    <item>
      <pubDate>Sun, 27 Jul 2008 14:27:02 -0400</pubDate>
      <title>Re: randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445712</link>
      <author>Bruno Luong</author>
      <description>&quot;ching l&quot; &amp;lt;chinglnc@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g6huta$4pa$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The error- Too many input arguments.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; wavplay (sample{randperm(6)});&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; because it's using six random numbers at a time.&lt;br&gt;
&amp;gt; I only want it to play one random number at a time.&lt;br&gt;
&amp;gt; That means, whenever I call the wavplay function, it will&lt;br&gt;
&amp;gt; randomly choose from 1 to 6, and when I call that function&lt;br&gt;
&amp;gt; again, it will choose from 1 to 6, but not the same number&lt;br&gt;
&amp;gt; that used before that.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
The problem is not randperm.&lt;br&gt;
&lt;br&gt;
The problem is you call functions that have output and input&lt;br&gt;
but without making sure the compatible between the number of&lt;br&gt;
output/input arguments, their type, etc. In the case&lt;br&gt;
&quot;waveplay&quot;, it accepts only ONE argument, whereas when you&lt;br&gt;
the expression:&lt;br&gt;
&lt;br&gt;
sample{randperm(6)}&lt;br&gt;
&lt;br&gt;
provides a list of SIX elements (MATLAB official term is&lt;br&gt;
&quot;Comma separate list&quot;). This is not allowed by waveplay.&lt;br&gt;
&lt;br&gt;
This is a typically problem of syntax. That is why people in&lt;br&gt;
this newsgroup encourage you do debug yourself and&lt;br&gt;
understand deeply MATLAB syntax, type, variable, workspace,&lt;br&gt;
etc... before asking question about rand and randperm.&lt;br&gt;
&lt;br&gt;
I suggest you to slow down and doing simple things with&lt;br&gt;
MATLAB syntax. You don't need randperm to see what is wrong.&lt;br&gt;
You should bump to the same error by doing the following:&lt;br&gt;
&lt;br&gt;
waveplay(sample{[1 2]})&lt;br&gt;
&lt;br&gt;
As long as you don't fully understand what is wrong with&lt;br&gt;
this syntax, you would hardly make any progress in&lt;br&gt;
programming with MATLAB.&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
    <item>
      <pubDate>Sun, 27 Jul 2008 14:55:03 -0400</pubDate>
      <title>Re: randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445715</link>
      <author>ching l</author>
      <description>&quot;Bruno Luong&quot; &amp;lt;b.luong@fogale.findmycountry&amp;gt; wrote in&lt;br&gt;
message &amp;lt;g6i0jm$kqb$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;ching l&quot; &amp;lt;chinglnc@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g6huta$4pa$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; The error- Too many input arguments.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; wavplay (sample{randperm(6)});&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; because it's using six random numbers at a time.&lt;br&gt;
&amp;gt; &amp;gt; I only want it to play one random number at a time.&lt;br&gt;
&amp;gt; &amp;gt; That means, whenever I call the wavplay function, it will&lt;br&gt;
&amp;gt; &amp;gt; randomly choose from 1 to 6, and when I call that function&lt;br&gt;
&amp;gt; &amp;gt; again, it will choose from 1 to 6, but not the same number&lt;br&gt;
&amp;gt; &amp;gt; that used before that.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The problem is not randperm.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The problem is you call functions that have output and input&lt;br&gt;
&amp;gt; but without making sure the compatible between the number of&lt;br&gt;
&amp;gt; output/input arguments, their type, etc. In the case&lt;br&gt;
&amp;gt; &quot;waveplay&quot;, it accepts only ONE argument, whereas when you&lt;br&gt;
&amp;gt; the expression:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; sample{randperm(6)}&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; provides a list of SIX elements (MATLAB official term is&lt;br&gt;
&amp;gt; &quot;Comma separate list&quot;). This is not allowed by waveplay.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This is a typically problem of syntax. That is why people in&lt;br&gt;
&amp;gt; this newsgroup encourage you do debug yourself and&lt;br&gt;
&amp;gt; understand deeply MATLAB syntax, type, variable, workspace,&lt;br&gt;
&amp;gt; etc... before asking question about rand and randperm.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I suggest you to slow down and doing simple things with&lt;br&gt;
&amp;gt; MATLAB syntax. You don't need randperm to see what is wrong.&lt;br&gt;
&amp;gt; You should bump to the same error by doing the following:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; waveplay(sample{[1 2]})&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; As long as you don't fully understand what is wrong with&lt;br&gt;
&amp;gt; this syntax, you would hardly make any progress in&lt;br&gt;
&amp;gt; programming with MATLAB.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Bruno&lt;br&gt;
&lt;br&gt;
yeah, I know about this problem. That's what I said, I'm not&lt;br&gt;
sure how to use randperm in wavplay in this case, because it&lt;br&gt;
has more than one argument. And I can't use rand because I&lt;br&gt;
can't fix the random argument.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Basically, I want the flexibility in randperm (which I can&lt;br&gt;
fix the array for the random), but I want the function in&lt;br&gt;
rand which it only output one arguement at a time.&lt;br&gt;
&lt;br&gt;
I'm thinking of a way of to save the randperm(n) into a&lt;br&gt;
column matrix and use it one by one controled by the&lt;br&gt;
program. Then use a counter(a variable) to count which&lt;br&gt;
random number is using. Then regenerate after the counter =&lt;br&gt;
n and reset the counter.&lt;br&gt;
&lt;br&gt;
Is this way make sense?</description>
    </item>
    <item>
      <pubDate>Sun, 27 Jul 2008 15:48:02 -0400</pubDate>
      <title>Re: randperm</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173308#445723</link>
      <author>Bruno Luong</author>
      <description>&quot;ching l&quot; &amp;lt;chinglnc@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g6i287$82n$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm thinking of a way of to save the randperm(n) into a&lt;br&gt;
&amp;gt; column matrix and use it one by one controled by the&lt;br&gt;
&amp;gt; program. Then use a counter(a variable) to count which&lt;br&gt;
&amp;gt; random number is using. Then regenerate after the counter =&lt;br&gt;
&amp;gt; n and reset the counter.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is this way make sense?&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Yes it makes more sense. You can even put the counter inside&lt;br&gt;
a wrapper function using PERSISTENT variable and let it roll&lt;br&gt;
automatically. But don't disperse. Try with your idea first,&lt;br&gt;
I think it's good.&lt;br&gt;
&lt;br&gt;
Bruno</description>
    </item>
  </channel>
</rss>

