Changlng a handles.variable size
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Is the size of a handles variable (ex., handles.data) fixed or can it be incremented? In my script, the handles.data changes its value with each listener update but does not increment as expected with vertcat. However, using a global variable instead, the global variable does increment as expected.
0 commentaires
Réponses (2)
Walter Roberson
le 17 Juil 2015
The sizes are definitely not fixed. However, be sure to use guidata() to update the "master" copy of the handles structure
function DoSomething(hObject, event, handles)
...
handles.somevariable = rand(5,10);
...
guidata(hObject, handles); %update master copy
end
0 commentaires
Steven Lord
le 17 Juil 2015
I'm assuming this is in the context of a GUI from the fact that you're referring to a handles structure. If you defined your listener function like:
addlistener(source, event, @(varargin) mycallback(handles))
then changes to the "master copy" of the handles structure associated with the GUI will NOT affect the COPY of the handles structure created when that anonymous function was created. If you want to do that, I would suggest passing in something that's not going to change (like the handle of your GUI's main figure window) and using that handle and GUIDATA retrieving a copy of the current master handles structure inside the callback.
0 commentaires
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!