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 17:21:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 87
Message-ID: <g62ghu$aq5$1@fred.mathworks.com>
References: <g5sevj$ra1$1@fred.mathworks.com> <muyprp78hzv.fsf@G99-Boettcher.llan.ll.mit.edu>
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 1216660862 11077 172.30.248.37 (21 Jul 2008 17:21:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 21 Jul 2008 17:21:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1438759
Xref: news.mathworks.com comp.soft-sys.matlab:480719



Peter Boettcher <boettcher@ll.mit.edu> wrote in message
<muyprp78hzv.fsf@G99-Boettcher.llan.ll.mit.edu>...
> "ching l" <chinglnc@hotmail.com> writes:
> 
> > Basically, the final outcome of the callback (or after the
> > push button is pressed) is a TEXT FILE, with the
> > corresponded information.
> >
> > I want these  1, 2, 3, 
> >               4, 5, 6, 
> >               7, 8, 9 
> >
> > to be in the text file. 
> >
> > Meaning to say, when the push button is first pressed, it
> > will create [1, 2, 3 ], then when it's pressed again, 
> > it will create [1, 2, 3, ; 4, 5, 6], and then when it's
> > pressed again, it will create [1, 2, 3; 4, 5, 6; 7, 8, 9] so
> > on and so forth. Then when the final push button is
pressed, 
> > it will create a text file with all these information in
there.
> 
> I think you have already learned how to store values in
"handles".  So
> keep going with that concept.  You will have two values in
"handles".
> One is the "number" of the callback.  That is, it starts at 0
> (initialize it as the GUI starts, like you did last time), and
> increments each time the button is pushed.
> 
> The other value in "handle" is the matrix.  As the
callback is called,
> look at the first value to decide how many times the
button was pushed
> already.  Add your new number to the matrix appropriately.
 And write
> the file when the number is > 3.  Or whenever you want.
> 
> 
> To learn MATLAB, or any programming language, it is an
essential skill
> to be able to separate a problem into small pieces.  In
this case:
> 
> Handle a button push via a callback.
> Store values between different callbacks.
> Execute different code based on a condition.
> Append rows to a matrix.
> Write a text file.
> Etc, etc.
> 
> Some of these you know how to do already.  Some you may
need to try to
> read the documentation.  And some you may need to post
here.  Once you
> have a plan, start coding.  Either go for broke and write
it all,
> debugging after that, or start with the bare minimum that
will show
> something.  Like increment the count (and display it) each
time the
> button is pushed.  That will make it easier to write and
debug the rest.
> 
> 
> 
> -Peter

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.