|
"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?
|