reference objects outside function workspace?

5 views (last 30 days)
I have a simulation. It is run by a timer; the time function notifies a bunch of objects of an event, and in their callback functions they update themselves and produce xml strings. I want to send all the xml to a socket in the same function that produces the xml. If i put the socket in the workspace and then these functions run, is there a way for them to use the socket even though it isn't in the scope of the function?

Accepted Answer

Walter Roberson
Walter Roberson on 12 Aug 2011
Yes. You could create an access method for it, or you could findobj() on it, or you could create a global variable, or you could use any of the techniques used to share data with graphic callbacks (see http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.3F)
or you could pass the object handle in to the timer callback, or ...
  1 Comment
Libby
Libby on 17 Aug 2011
I ended up using a global variable and it works great. Thanks!

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!