Path: news.mathworks.com!not-for-mail
From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: randperm
Date: Sun, 27 Jul 2008 14:27:02 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 45
Message-ID: <g6i0jm$kqb$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>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
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 1217168822 21323 172.30.248.35 (27 Jul 2008 14:27:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 27 Jul 2008 14:27:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: news.mathworks.com comp.soft-sys.matlab:482066



"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