GUI operations on matlab objects (non-GUI)

2 visualizaciones (últimos 30 días)
Sean
Sean el 15 de Nov. de 2011
I am having difficulty updating an object that I am using in a GUI callback. I am sure there must be a good way around it that I am missing because of my own lack of knowledge. If anyone can help me get around the problem (without undue hardship ;) ), I would appreciate it.
1)Say that I have an object 'obj' with internal variables 'varx' and 'vary'.
2)Say that, within a method of obj, I update obj.varx.
In order to keep the update beyond the duration of the method call, I need to return the object. [e.g. obj = obj.method(...);]
If I pass obj to a GUI callback and perform this operation, I cannot update obj in the main GUI function, because callbacks do not return output. (ex. set(h.toggle_exp, 'Callback', {@toggle, obj, othervar}); Using guidata() doesn't update particular variables, either.
Is the only way to update objects in the parent GUI function to define them as globals? (I hope not, ... ughh ...)
Any thoughts on how to a) update parent object within methods, and/or b) update particular variables within parent function would be awesome.
Thanks in advance, Sean

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Nov. de 2011
You can assignin('caller') but when you are in a GUI callback, the caller is the the base MATLAB workspace. The main GUI function is not a "parent function" to a callback.
You can use nested functions and thus nested variables. This is probably the best way.

Más respuestas (1)

Sean de Wolski
Sean de Wolski el 15 de Nov. de 2011
And there's always get/setappdata:
doc setappdata
doc getappdata

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by