Path: news.mathworks.com!not-for-mail
From: "ching l" <chinglnc@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: repetitive counter (GUI)
Date: Wed, 15 Jul 2009 07:34:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 109
Message-ID: <h3k0pa$sg9$1@fred.mathworks.com>
References: <h3g5v9$6ep$1@fred.mathworks.com> <h3g6rd$58f$1@fred.mathworks.com> <h3g7ie$mr4$1@fred.mathworks.com> <h3g8bd$lin$1@news.eternal-september.org> <h3hbh5$ljn$1@fred.mathworks.com> <h3hgfb$96h$1@news.eternal-september.org> <h3i04f$90p$1@fred.mathworks.com> <h3i1jj$r9o$1@news.eternal-september.org> <h3i1oe$q5s$1@fred.mathworks.com> <h3itgh$cs9$1@fred.mathworks.com> <h3j5kc$9je$1@news.eternal-september.org>
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 1247643242 29193 172.30.248.35 (15 Jul 2009 07:34:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 15 Jul 2009 07:34:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1438759
Xref: news.mathworks.com comp.soft-sys.matlab:555543


dpb <none@non.net> wrote in message <h3j5kc$9je$1@news.eternal-september.org>...
> ching l wrote:
> ...
> > handles = guidata(gcbo); 
> > if(handles.count<=2) 
> >   handles.count= handles.count+1;
> > handles.count =    count


> > else 
> >   set(hObject, 'enable', 'off') 
> > end
> > guidata(gcbo, handles);
> > ...
> > handles.randValue=299+handles.count;
> > play= handles.randvalue
> > ...
> > 
> > --------------------
> > The results are
> > 
> > count= 0     play= 300 ;
> > count= 1     play= 301 ;
> > count = 2    play = 302 ;
> > play= 302 ;  disable button
> > 
> > ----------------------
> > 
> > what I want is 
> > count= 0     play= 300 ;
> > count= 1     play= 301 ;
> > count = 2    play = 302 ;
> > disable button
> > 
> > can anyone tell me whether my logic is not right or the codes are not right?
> 
> Not from this, no--there's no way the output you've listed could have 
> been generated from this code -- one needs _PRECISELY_AND_IDENTICALLY_, 
> _WITHOUT_ANY_EDITING_ for presentation the code that generated the 
> output, also not edited...
> 
> For example, the output says "count" but the line w/o a semicolon is
> 
>  > handles.count= count
> 
> which would display "handles.count = 0" assuming count is 0 on entry.
> 
> Perhaps, in fact, therein is part of the problem--you increment
> handles.count and then set it to count which will in essence undoes the 
> increment operation.
> 
> I suspect your problems are tied in with this problem...
> 
> --I'm sorry,  i've accidentally edited that line when I try to make the codes look more reasonable..

it should be count= handles.count and that's the value that display on the matlab command window. I'm not sure what you mean by "you increment
handles.count and then set it to count which will in essence undoes the 
increment operation." Would you mind to explain a little bit?

Anyway the codes should look like this-

handles = guidata(gcbo);

if(handles.count<=2)

handles.count= handles.count+1;

count = handles.count

else

set(hObject, 'enable', 'off')

end

guidata(gcbo, handles);

[audio, fs] = wavread('C:\a.wav');
samples{300} = {audio, fs};

[audio, fs] = wavread('C:\b.wav');
samples{301} = {audio, fs};

[audio, fs] = wavread('C:\b.wav');
samples{302} = {audio, fs};

handles.randValue=299+handles.count;

play= handles.randvalue

wavplay(samples{handles.randValue}{:}) ;
 
guidata(hObject, handles);

--------------------
The results are

count= 0 play= 300 ;
count= 1 play= 301 ;
count = 2 play = 302 ;
play= 302 ; disable button

----------------------

what I want is
count= 0 play= 300 ;
count= 1 play= 301 ;
count = 2 play = 302 ;
disable button