Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Handles
Date: Thu, 11 Dec 2008 03:05:05 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 46
Message-ID: <ghq011$7rf$1@fred.mathworks.com>
References: <ghpjqu$7jn$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1228964705 8047 172.30.248.37 (11 Dec 2008 03:05:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 11 Dec 2008 03:05:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869871
Xref: news.mathworks.com comp.soft-sys.matlab:506252


"Chris " <chris.crawshaw@gmail.com> wrote in message <ghpjqu$7jn$1@fred.mathworks.com>...
> Hi all,
> I've been trying to learn about the 'handles' thing that appears in GUIDE scripts I've downloaded and in scripts I've downloaded from here. I just can't seem to get my head around it.
> I have uploaded an example of my script where I haven't used this at all but it needs to be reviewed - I'll add the link when it becomes available.
> 
> However, in the meantime, an example of a function nested within my GUI is:
>     m3=uicontrol(fig,...
>         'style','pop');
>     function calcbutton(source,eventdata); %push to calculate button
>         str3=get(m3,'string');
>         val3=get(m3,'value');
>     end
> 
> I assume, using handles provides benifits which aren't apparent at the moment. Any advice on where to use this or where to research it would be greatly appreciated.
> 
> An example of the code I'm struggling to understand:
> function pushbutton1_Callback(hObject, eventdata, handles)
> % hObject    handle to pushbutton1 (see GCBO)
> % eventdata  reserved - to be defined in a future version of MATLAB
> % handles    structure with handles and user data (see GUIDATA)
> saveState(handles)
> 
> I have read the help files on GUIDATA and GUIHANDLES but still don't understand it I'm afraid.
> 
> Cheers,
> Chris

Chris,

Is it okay to assume that you read through the "Creating GUIs with GUIDE" section of the documentation?

http://www.mathworks.com/access/helpdesk/help/techdoc/creating_guis/bqz6p81.html

The above page is also found by typing the following in the Command Window:

web([docroot,'/techdoc/creating_guis/bqz6p81.html'])

One thing to note is that GUIDE-generated files don't use Nested Functions, so mixing them inside may have some adverse effects. "handles" variable is used to give user the access to various graphics components in your GUI, and it allows you to change and set properties. You can store user data to "handles", and you can use GUIDATA to update "handles" so that other GUI components in your GUI will have access to it.

I suggest you take a look at some of the videos here:

http://blogs.mathworks.com/videos/category/gui-or-guide/

The two videos at the end may give you the basics to help you get your head around the concepts.

jiro