Path: news.mathworks.com!newsfeed-00.mathworks.com!panix!bloom-beacon.mit.edu!llnews!53ab2750!not-for-mail
From: Peter Boettcher <boettcher@ll.mit.edu>
Newsgroups: comp.soft-sys.matlab
Subject: Re: : [ ] function?
References: <g5sevj$ra1$1@fred.mathworks.com>
Message-ID: <muyprp78hzv.fsf@G99-Boettcher.llan.ll.mit.edu>
Organization: MIT Lincoln Laboratory
User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/23.0.0 (gnu/linux)
Cancel-Lock: sha1:6X1UBSqvXW1NEOfz/m8DQvJORbA=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Lines: 51
Date: Mon, 21 Jul 2008 09:49:24 -0400
NNTP-Posting-Host: 155.34.163.114
X-Complaints-To: news@ll.mit.edu
X-Trace: llnews 1216647422 155.34.163.114 (Mon, 21 Jul 2008 09:37:02 EDT)
NNTP-Posting-Date: Mon, 21 Jul 2008 09:37:02 EDT
Xref: news.mathworks.com comp.soft-sys.matlab:480666



"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