Changlng a handles.variable size

3 Ansichten (letzte 30 Tage)
Bill Saidel
Bill Saidel am 17 Jul. 2015
Beantwortet: Steven Lord am 17 Jul. 2015
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.

Antworten (2)

Walter Roberson
Walter Roberson am 17 Jul. 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

Steven Lord
Steven Lord am 17 Jul. 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.

Kategorien

Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by