Thread Subject: no repeat for rand

Subject: no repeat for rand

From: ching l

Date: 24 Jul, 2008 07:29:02

Message: 1 of 11

is it possible to limit rand value so that it doesn't repeat?
Which each of these file is only play one time

a{3} = {audio, fs};

a{4} = {audio, fs};

a{5} = {audio, fs};

wavplay(a{ceil(length(samples)*rand)}{:})

Thanks


Subject: no repeat for rand

From: us

Date: 24 Jul, 2008 07:39:03

Message: 2 of 11

"ching l":
<SNIP nonrandomly randomness...

> is it possible to limit rand value so that it doesn't
repeat...

a hint:

     help randperm;

us

Subject: no repeat for rand

From: ching l

Date: 24 Jul, 2008 08:55:23

Message: 3 of 11

"us " <us@neurol.unizh.ch> wrote in message
<g69bin$ff5$1@fred.mathworks.com>...
> "ching l":
> <SNIP nonrandomly randomness...
>
> > is it possible to limit rand value so that it doesn't
> repeat...
>
> a hint:
>
> help randperm;
>
> us


It says exceeds matrix dimensions, any idea why?

a{5} = {audio, fs};

fixrand= ceil(length(samples)*rand);
fixrand= randperm(5);

wavplay(a{fixrand)}{:});


Subject: no repeat for rand

From: David

Date: 24 Jul, 2008 11:44:23

Message: 4 of 11

"ching l" <chinglnc@hotmail.com> wrote in message
<g69g1r$60c$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message
> <g69bin$ff5$1@fred.mathworks.com>...
> > "ching l":
> > <SNIP nonrandomly randomness...
> >
> > > is it possible to limit rand value so that it
doesn't
> > repeat...
> >
> > a hint:
> >
> > help randperm;
> >
> > us
>
>
> It says exceeds matrix dimensions, any idea why?
>
> a{5} = {audio, fs};
>
> fixrand= ceil(length(samples)*rand);
> fixrand= randperm(5);
>
> wavplay(a{fixrand)}{:});
>
>

start over... you are assigning 2 values of fixrand
without doing anything with the first one. and your ()
and {} don't match up in your wavplay function. then what
are audio and fs?

Subject: no repeat for rand

From: ching l

Date: 24 Jul, 2008 13:03:11

Message: 5 of 11

"David " <dave@bigcompany.com> wrote in message
<g69pun$lo$1@fred.mathworks.com>...
> "ching l" <chinglnc@hotmail.com> wrote in message
> <g69g1r$60c$1@fred.mathworks.com>...
> > "us " <us@neurol.unizh.ch> wrote in message
> > <g69bin$ff5$1@fred.mathworks.com>...
> > > "ching l":
> > > <SNIP nonrandomly randomness...
> > >
> > > > is it possible to limit rand value so that it
> doesn't
> > > repeat...
> > >
> > > a hint:
> > >
> > > help randperm;
> > >
> > > us
> >
> >
> > It says exceeds matrix dimensions, any idea why?
> >
> > a{5} = {audio, fs};
> >
> > fixrand= ceil(length(samples)*rand);
> > fixrand= randperm(5);
> >
> > wavplay(a{fixrand)}{:});
> >
> >
>
> start over... you are assigning 2 values of fixrand
> without doing anything with the first one. and your ()
> and {} don't match up in your wavplay function. then what
> are audio and fs?

sorry...it supposed to be

[audio, fs] = wavread('G:\wyei.wav');
a{5} = {audio, fs};
 
fixrand= ceil(length(samples)*rand);
fixrand= randperm(5);

wavplay(a{fixrand)}{:});

Subject: no repeat for rand

From: David

Date: 24 Jul, 2008 13:44:02

Message: 6 of 11

"ching l" <chinglnc@hotmail.com> wrote in message
<g69uif$nne$1@fred.mathworks.com>...
> "David " <dave@bigcompany.com> wrote in message
> <g69pun$lo$1@fred.mathworks.com>...
> > "ching l" <chinglnc@hotmail.com> wrote in message
> > <g69g1r$60c$1@fred.mathworks.com>...
> > > "us " <us@neurol.unizh.ch> wrote in message
> > > <g69bin$ff5$1@fred.mathworks.com>...
> > > > "ching l":
> > > > <SNIP nonrandomly randomness...
> > > >
> > > > > is it possible to limit rand value so that it
> > doesn't
> > > > repeat...
> > > >
> > > > a hint:
> > > >
> > > > help randperm;
> > > >
> > > > us
> > >
> > >
> > > It says exceeds matrix dimensions, any idea why?
> > >
> > > a{5} = {audio, fs};
> > >
> > > fixrand= ceil(length(samples)*rand);
> > > fixrand= randperm(5);
> > >
> > > wavplay(a{fixrand)}{:});
> > >
> > >
> >
> > start over... you are assigning 2 values of fixrand
> > without doing anything with the first one. and your
()
> > and {} don't match up in your wavplay function. then
what
> > are audio and fs?
>
> sorry...it supposed to be
>
> [audio, fs] = wavread('G:\wyei.wav');
> a{5} = {audio, fs};
>
> fixrand= ceil(length(samples)*rand);
> fixrand= randperm(5);
>
> wavplay(a{fixrand)}{:});
>

thats one step better... but you still have 2 assignments
to fixrand without using the first one, and the () and {}
in the wavplay don't match up.

Subject: no repeat for rand

From: ching l

Date: 24 Jul, 2008 14:18:02

Message: 7 of 11

"David " <dave@bigcompany.com> wrote in message
<g6a0v2$rtq$1@fred.mathworks.com>...
> "ching l" <chinglnc@hotmail.com> wrote in message
> <g69uif$nne$1@fred.mathworks.com>...
> > "David " <dave@bigcompany.com> wrote in message
> > <g69pun$lo$1@fred.mathworks.com>...
> > > "ching l" <chinglnc@hotmail.com> wrote in message
> > > <g69g1r$60c$1@fred.mathworks.com>...
> > > > "us " <us@neurol.unizh.ch> wrote in message
> > > > <g69bin$ff5$1@fred.mathworks.com>...
> > > > > "ching l":
> > > > > <SNIP nonrandomly randomness...
> > > > >
> > > > > > is it possible to limit rand value so that it
> > > doesn't
> > > > > repeat...
> > > > >
> > > > > a hint:
> > > > >
1.> > > > > help randperm;
> > > > >
> > > > > us
> > > >
> > > >
> > > > It says exceeds matrix dimensions, any idea why?
> > > >
> > > > a{5} = {audio, fs};
> > > >
> > > > fixrand= ceil(length(samples)*rand);
> > > > fixrand= randperm(5);
> > > >
> > > > wavplay(a{fixrand)}{:});
> > > >
> > > >
> > >
> > > start over... you are assigning 2 values of fixrand
> > > without doing anything with the first one. and your
> ()
> > > and {} don't match up in your wavplay function. then
> what
> > > are audio and fs?
> >
> > sorry...it supposed to be
> >
> > [audio, fs] = wavread('G:\wyei.wav');
> > a{5} = {audio, fs};
> >
> > fixrand= ceil(length(samples)*rand);
> > fixrand= randperm(5);
> >
> > wavplay(a{fixrand)}{:});
> >
>
> thats one step better... but you still have 2 assignments
> to fixrand without using the first one, and the () and {}
> in the wavplay don't match up.

sorry, I definitely not a bright person, I need a bit
explanation of this please

1.you still have 2 assignments to fixrand without using the
first one

2. ) and {} in the wavplay don't match up.

Subject: no repeat for rand

From: David

Date: 24 Jul, 2008 14:28:01

Message: 8 of 11

"ching l" <chinglnc@hotmail.com> wrote in message
<g6a2uq$s86$1@fred.mathworks.com>...

> > > [audio, fs] = wavread('G:\wyei.wav');
> > > a{5} = {audio, fs};
> > >
> > > fixrand= ceil(length(samples)*rand);
> > > fixrand= randperm(5);
> > >
> > > wavplay(a{fixrand)}{:});
> > >
> >
> > thats one step better... but you still have 2
assignments
> > to fixrand without using the first one, and the () and
{}
> > in the wavplay don't match up.
>
> sorry, I definitely not a bright person, I need a bit
> explanation of this please
>
> 1.you still have 2 assignments to fixrand without using
the
> first one
>
> 2. ) and {} in the wavplay don't match up.

you have these two steps... you assign a value to fixrand,
then you assign another value to it, so the first one is
lost. why do the first one??

fixrand= ceil(length(samples)*rand);
fixrand= randperm(5);

in this statement remove the text and just leave the ()
and {}:
wavplay(a{fixrand)}{:});
and you get:
({)}{})
note that you have ({ then a ) without closing the }.

Subject: no repeat for rand

From: Peter Boettcher

Date: 24 Jul, 2008 18:05:02

Message: 9 of 11

"ching l" <chinglnc@hotmail.com> writes:

> "David " <dave@bigcompany.com> wrote in message
> <g6a0v2$rtq$1@fred.mathworks.com>...
>> "ching l" <chinglnc@hotmail.com> wrote in message
>> <g69uif$nne$1@fred.mathworks.com>...

>> > [audio, fs] = wavread('G:\wyei.wav');
>> > a{5} = {audio, fs};
>> >
>> > fixrand= ceil(length(samples)*rand);
>> > fixrand= randperm(5);
>> >
>> > wavplay(a{fixrand)}{:});
>> >
>>
>> thats one step better... but you still have 2 assignments
>> to fixrand without using the first one, and the () and {}
>> in the wavplay don't match up.
>
> sorry, I definitely not a bright person, I need a bit
> explanation of this please
>
> 1.you still have 2 assignments to fixrand without using the
> first one

If I say:

a = 5;
a = 4;

What value does "a" have right now? What use is the first line?

I highly recommend finding a class for beginner programming. Through
your company, through your university, somewhere. Many of the questions
you have are not really MATLAB questions, they are more related to the
basics of thinking about programming. I mean no offence, I think this
would be worth your time and money if you plan on continuing to work in
MATLAB.


-Peter

Subject: no repeat for rand

From: ching l

Date: 24 Jul, 2008 18:17:40

Message: 10 of 11


> I highly recommend finding a class for beginner
programming. Through
> your company, through your university, somewhere. Many of
the questions
> you have are not really MATLAB questions, they are more
related to the
> basics of thinking about programming. I mean no offence,
I think this
> would be worth your time and money if you plan on
continuing to work in
> MATLAB.
>
>
> -Peter

I knew it, Peter..

and I'm really working on it, I'm trying my best to get the
logical sense right!!

I really appreciated every single helps from the forum for a
naive like me...really...it meant so much to me..

thanks for your advice.


Subject: no repeat for rand

From: ching l

Date: 25 Jul, 2008 21:14:02

Message: 11 of 11

"David " <dave@bigcompany.com> wrote in message
<g6a3hh$6cu$1@fred.mathworks.com>...
> "ching l" <chinglnc@hotmail.com> wrote in message
> <g6a2uq$s86$1@fred.mathworks.com>...
>
> > > > [audio, fs] = wavread('G:\wyei.wav');
> > > > a{5} = {audio, fs};
> > > >
> > > > fixrand= ceil(length(samples)*rand);
> > > > fixrand= randperm(5);
> > > >
> > > > wavplay(a{fixrand)}{:});
> > > >
> > >
> > > thats one step better... but you still have 2
> assignments
> > > to fixrand without using the first one, and the () and
> {}
> > > in the wavplay don't match up.
> >
> > sorry, I definitely not a bright person, I need a bit
> > explanation of this please
> >
> > 1.you still have 2 assignments to fixrand without using
> the
> > first one
> >
> > 2. ) and {} in the wavplay don't match up.
>
> you have these two steps... you assign a value to fixrand,
> then you assign another value to it, so the first one is
> lost. why do the first one??
>
> fixrand= ceil(length(samples)*rand);
> fixrand= randperm(5);
>
> in this statement remove the text and just leave the ()
> and {}:
> wavplay(a{fixrand)}{:});
> and you get:
> ({)}{})
> note that you have ({ then a ) without closing the }.
>

Did you mean like this?

fixrand= randperm(5);
wavplay({)}{});

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
randperm ching l 24 Jul, 2008 04:55:34
reference us 24 Jul, 2008 03:40:09
randperm us 24 Jul, 2008 03:40:09
rand ching l 24 Jul, 2008 03:30:07
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com