MATLAB: Reference objects outside function workspace

objects outside functions

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?

Best Answer

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 ...