Path: news.mathworks.com!not-for-mail
From: "ching l" <chinglnc@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: : [ ] function?
Date: Mon, 21 Jul 2008 18:37:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 76
Message-ID: <g62l0f$soe$1@fred.mathworks.com>
References: <g5sevj$ra1$1@fred.mathworks.com> <muyvdyz6qse.fsf@G99-Boettcher.llan.ll.mit.edu>
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 1216665423 29454 172.30.248.38 (21 Jul 2008 18:37:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 21 Jul 2008 18:37:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1438759
Xref: news.mathworks.com comp.soft-sys.matlab:480734



Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muyvdyz6qse.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "ching l" <chinglnc@hotmail.com> writes:
> 
> > Peter Boettcher <boettcher@ll.mit.edu> wrote in message
> > <muyzlob6td6.fsf@G99-Boettcher.llan.ll.mit.edu>...
> >> "ching l" <chinglnc@hotmail.com> writes:
> >> 
> >> > Thanks Peter. That's really helpful. I sort of get
the idea
> >> > of doing this in Matlab command, but not in Gui. As
I'm not
> >> > so sure how to create a Matrix function. That's what I
> >> > thought which I did it in Matlab. 
> >> >
> >> > a= [1, 2, 3];
> >> > b= [a;1, 2, 3];
> >> > c= [b; 1, 2, 3];
> >> >
> >> > then finally write the matrix into text file.
> >> >
> >> > But Gui doesn't understand what is 
> >> > a= [1, 2, 3]; because that's not a function. 
> >> >
> >> > What I want is, when the callback function is called,
it can
> >> > create a= [1, 2, 3]. As simple as that.
> >> 
> >> Don't change how you create or call the callback
function.  Just put
> >> that code in the body of the callback function.  The
header of the
> >> function, and the 'Callback' property of the GUI, will
look exactly
> >> the same as it did before.
> >> 
> >> -Peter
> >
> > Did I miss something? That's what I did but nothing
> > happened....did you mean this?
> >
> > function  answer_nochange_Callback(hObject, eventdata,
handles)
> >
> > a= [1, 2, 3];
> 
> Yes, I mean this.  And it does exactly what you told it
to.  It creates
> a variable "a" in the workspace of the callback function.
 Now go back
> to what you did before to store "randValue", so that it
would be
> accessible from one callback to the next.
> 
> Do you get that's why you have to do all that stuff with
handles and
> guidata?  Like all functions, once the callback function
exits, all its
> variables disappear.  When you want data to persist, you
have to do
> something else with it.  And the most natural thing when
you're writing
> a GUI is to associate your persistent data with the GUI
itself, which is
> exactly what "handles" and "guidata" are for.
> 
> Now take that code that someone else helped you with and
extend the
> concept to this other stuff you'd like to do now.
> 
> -Peter

my problem is, it doesnt do this- "It creates a variable "a"
in the workspace of the callback function"...

any idea why is it so?