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 05:52:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 67
Message-ID: <g63si1$5h5$1@fred.mathworks.com>
References: <g5n6am$78p$1@fred.mathworks.com> <g5r2ls$4l8$1@canopus.cc.umanitoba.ca>
Reply-To: "ching l" <chinglnc@hotmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1216705921 5669 172.30.248.37 (22 Jul 2008 05:52:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 22 Jul 2008 05:52:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1438759
Xref: news.mathworks.com comp.soft-sys.matlab:480841



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.s {counter} = [(handles.id), (handles.randValue), 2] 

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

handles.s= [handles{count}, handles{count-1};]

so let say handles.s {1} = [1, 2, 3];
           handles.s {2} = [4, 5, 6]; handles {1};
           handles.s {3} = [7, 8, 9]: handles {2};
             

so on and so forth...