Path: news.mathworks.com!not-for-mail
From: "ching l" <chinglnc@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: go to next function in one callback?
Date: Tue, 22 Jul 2008 09:09:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 70
Message-ID: <g6483f$7be$1@fred.mathworks.com>
References: <g5n6am$78p$1@fred.mathworks.com> <g5r2ls$4l8$1@canopus.cc.umanitoba.ca> <g63si1$5h5$1@fred.mathworks.com>
Reply-To: "ching l" <chinglnc@hotmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1216717743 7534 172.30.248.38 (22 Jul 2008 09:09:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 22 Jul 2008 09:09:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1438759
Xref: news.mathworks.com comp.soft-sys.matlab:480856



"ching l" <chinglnc@hotmail.com> wrote in message
<g63si1$5h5$1@fred.mathworks.com>...
> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in
> message <g5r2ls$4l8$1@canopus.cc.umanitoba.ca>...
> > In article <g5n6am$78p$1@fred.mathworks.com>,
> > ching l <chinglnc@hotmail.com> wrote:
> > >In Gui, how do I command the callback function to go to the
> > >next function?
> > 
> > >For example, when I first press the button, it will go to
> this, 
> > 
> > >function answer_faster_Callback(hObject, eventdata,
handles)
> > >csvwrite('subject1.dat',[1;00;55]);
> > 
> > >then when I press again, it will go to this, 
> > 
> > >csvwrite('subject2.dat',[3;5;6]);
> > 
> > >Possible to do that?
> > 
> > Yes,
> > 
> > function answer_faster_Callback(hObject, eventdata, handles)
> >   persistent fargs
> >   if isempty(fargs)
> >     fargs.args = {{'subject1.dat',[1;00;55]}, {'subject2',
> [3;5;6]}, ...
> >                   {'subject3.dat',[17;8;21]}, {'subject4',
> [255;0;255]};
> >     fargs.count = 1;
> >   end
> > 
> >   csvwrite(fargs.args{fargs.count,1},
> fargs.args{fargs.count,2});
> >   fargs.count = fargs.count + 1;
> >   if fargs.count > length(fargs.args)
> >      set(hObject, 'Callback', '');
> >   end
> > end
> > -- 
> > Q: Why did the chicken cross the Mobius strip?
> > 
> > A: There were manifold reasons.
> 
> 
> I got some changes of this...not very sure how to work it
out...
> 
 Is it possible to retain the previous value of the
callback? something like this, but I know this is not right.
I want the callback to store the previous count value and
store in current count value


handles.scount= 1;
handles.scount= handles.scount+1;

handles.sc{handles.scount}= [handles.id,
(handles.randValue), 2] 

handles.s = [handles.sc{handles.scount};
handles.sc{handles.scount-1}] 

guidata(hObject, handles);


it still doesn't return the previous count value..any idea how?