Path: news.mathworks.com!not-for-mail
From: "ching l" <chinglnc@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: randperm
Date: Sun, 27 Jul 2008 14:55:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 70
Message-ID: <g6i287$82n$1@fred.mathworks.com>
References: <g6fu97$7ru$1@fred.mathworks.com> <g6g0ia$vp$1@fred.mathworks.com> <g6g1m3$cec$1@fred.mathworks.com> <g6hdm9$j18$1@fred.mathworks.com> <g6hqc7$gck$1@fred.mathworks.com> <g6hr97$sq6$1@fred.mathworks.com> <g6huta$4pa$1@fred.mathworks.com> <g6i0jm$kqb$1@fred.mathworks.com>
Reply-To: "ching l" <chinglnc@hotmail.com>
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 1217170503 8279 172.30.248.35 (27 Jul 2008 14:55:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 27 Jul 2008 14:55:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1438759
Xref: news.mathworks.com comp.soft-sys.matlab:482069



"Bruno Luong" <b.luong@fogale.findmycountry> wrote in
message <g6i0jm$kqb$1@fred.mathworks.com>...
> "ching l" <chinglnc@hotmail.com> wrote in message
> <g6huta$4pa$1@fred.mathworks.com>...
> 
> > 
> > The error- Too many input arguments.
> > 
> > wavplay (sample{randperm(6)});
> > 
> > because it's using six random numbers at a time.
> > I only want it to play one random number at a time.
> > That means, whenever I call the wavplay function, it will
> > randomly choose from 1 to 6, and when I call that function
> > again, it will choose from 1 to 6, but not the same number
> > that used before that.
> > 
> 
> The problem is not randperm.
> 
> The problem is you call functions that have output and input
> but without making sure the compatible between the number of
> output/input arguments, their type, etc. In the case
> "waveplay", it accepts only ONE argument, whereas when you
> the expression:
> 
> sample{randperm(6)}
> 
> provides a list of SIX elements (MATLAB official term is
> "Comma separate list"). This is not allowed by waveplay.
> 
> This is a typically problem of syntax. That is why people in
> this newsgroup encourage you do debug yourself and
> understand deeply MATLAB syntax, type, variable, workspace,
> etc... before asking question about rand and randperm.
> 
> I suggest you to slow down and doing simple things with
> MATLAB syntax. You don't need randperm to see what is wrong.
> You should bump to the same error by doing the following:
> 
> waveplay(sample{[1 2]})
> 
> As long as you don't fully understand what is wrong with
> this syntax, you would hardly make any progress in
> programming with MATLAB.
> 
> Bruno

yeah, I know about this problem. That's what I said, I'm not
sure how to use randperm in wavplay in this case, because it
has more than one argument. And I can't use rand because I
can't fix the random argument.


Basically, I want the flexibility in randperm (which I can
fix the array for the random), but I want the function in
rand which it only output one arguement at a time.

I'm thinking of a way of to save the randperm(n) into a
column matrix and use it one by one controled by the
program. Then use a counter(a variable) to count which
random number is using. Then regenerate after the counter =
n and reset the counter.

Is this way make sense?