Changlng a handles.variable size
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Walter Roberson
il 17 Lug 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 Commenti
Steven Lord
il 17 Lug 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 Commenti
Vedere anche
Categorie
Scopri di più su Creating, Deleting, and Querying Graphics Objects in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!