Thread Subject: Can the handles structure be referenced or called in a function that isn't a callback?

Subject: Can the handles structure be referenced or called in a function that isn't a callback?

From: Brad Henrie

Date: 8 Jul, 2009 00:47:01

Message: 1 of 7

Can the handles structure be referenced or called in a function that isn't a callback? I want to use a function to make my code seem shorter and to control propertyvalues of objects. To do that I need to access the handles structure from a function but so far I am unable to do that. Any ideas on how to do this would be greatly appreciated. Thank you.

Subject: Can the handles structure be referenced or called in a function that isn't a callback?

From: Matt Fig

Date: 8 Jul, 2009 01:00:19

Message: 2 of 7

Pass the handles structure to the function.

Subject: Can the handles structure be referenced or called in a function that isn't a callback?

From: Travis

Date: 7 Aug, 2009 18:28:02

Message: 3 of 7

"Matt Fig" <spamanon@yahoo.com> wrote in message <h30r33$224$1@fred.mathworks.com>...
> Pass the handles structure to the function.

I have done this and while I can then put a graph in axes using plot(handles.axes1,etc) I cannot set other items; i.e. cannot use set(handles.Sum,'string''for'). How would I go about doing this?

Subject: Can the handles structure be referenced or called in a function that isn't a callback?

From: Andy

Date: 7 Aug, 2009 18:48:01

Message: 4 of 7

"Travis " <sinusoid2@hotmail.com> wrote in message <h5hrni$bal$1@fred.mathworks.com>...
> "Matt Fig" <spamanon@yahoo.com> wrote in message <h30r33$224$1@fred.mathworks.com>...
> > Pass the handles structure to the function.
>
> I have done this and while I can then put a graph in axes using plot(handles.axes1,etc) I cannot set other items; i.e. cannot use set(handles.Sum,'string''for'). How would I go about doing this?

Post your code that's not working.

Subject: Can the handles structure be referenced or called in a function

From: ImageAnalyst

Date: 7 Aug, 2009 18:56:11

Message: 5 of 7

On Aug 7, 2:28 pm, "Travis " <sinuso...@hotmail.com> wrote:
> "Matt Fig" <spama...@yahoo.com> wrote in message <h30r33$22...@fred.mathworks.com>...
> > Pass the handles structure to the function.
>
> I have done this and while I can then put a graph in axes using plot(handles.axes1,etc) I cannot set other items; i.e. cannot use set(handles.Sum,'string''for').  How would I go about doing this?

---------------------------------------------------------------------------------
Works for me. Here's an example from my code:

%=====================================================================
% Change the caption on the button depending on how many items
% are selected in the listbox.
function UpdateAnalyzeButtonCaption(hObject, eventdata, handles)
Selected = get(handles.lstImageList, 'value');
if length(Selected) > 1
buttonCaption = {'Step 6: Analyze '}; % MATLAB quirk - needs to be
cell array to keep trailing spaces.
buttonCaption = strcat(buttonCaption, num2str(length(Selected)));
buttonCaption = strcat(buttonCaption, ' images');
set(handles.btnAnalyze, 'string', buttonCaption);
elseif length(Selected) == 1
set(handles.btnAnalyze, 'string', {'Step 6: Analyze 1 image'});
else
set(handles.btnAnalyze, 'string', {'Step 6: Analyze no images'});
end
return;

Subject: Can the handles structure be referenced or called in a function that isn't a callback?

From: Matt Fig

Date: 7 Aug, 2009 19:02:03

Message: 6 of 7

"Travis " <sinusoid2@hotmail.com> wrote in message <h5hrni$bal$1@fred.mathworks.com>...
> "Matt Fig" <spamanon@yahoo.com> wrote in message <h30r33$224$1@fred.mathworks.com>...
> > Pass the handles structure to the function.
>
> I have done this and while I can then put a graph in axes using plot(handles.axes1,etc) I cannot set other items; i.e. cannot use set(handles.Sum,'string''for'). How would I go about doing this?



Did those other items belong to the structure when it was passed, or were they added after the fact?

Subject: Can the handles structure be referenced or called in a function that isn't a callback?

From: Travis

Date: 7 Aug, 2009 19:38:02

Message: 7 of 7

"Matt Fig" <spamanon@yahoo.com> wrote in message <h5htnb$no2$1@fred.mathworks.com>...
> "Travis " <sinusoid2@hotmail.com> wrote in message <h5hrni$bal$1@fred.mathworks.com>...
> > "Matt Fig" <spamanon@yahoo.com> wrote in message <h30r33$224$1@fred.mathworks.com>...
> > > Pass the handles structure to the function.
> >
> > I have done this and while I can then put a graph in axes using plot(handles.axes1,etc) I cannot set other items; i.e. cannot use set(handles.Sum,'string''for'). How would I go about doing this?
>
>
>
> Did those other items belong to the structure when it was passed, or were they added after the fact?

handles.Sum exists, but it is only a number, I cannot use get(handles.Sum) to see the properties of it.

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
function Brad Henrie 7 Jul, 2009 20:49:05
handles Brad Henrie 7 Jul, 2009 20:49:05
structure Brad Henrie 7 Jul, 2009 20:49:05
propertyvalues Brad Henrie 7 Jul, 2009 20:49:04
rssFeed for this Thread

Contact us at files@mathworks.com