Why Does Handles Overwrite This Variable?
Show older comments
I have created a GUI with only two push buttons and then replaced the callback functions of these two push buttons with the code below:
function pushbutton1_Callback(hObject, eventdata, handles)
handles.MyValue1 = 4;
assignin('base', 'handles', handles);
function pushbutton2_Callback(hObject, eventdata, handles)
handles.MyValue2 = 2;
assignin('base', 'handles', handles);
When I run this GUI and press pushbutton1, MyValue1 appears in the struct handles (visible in the Variables Window). When I press pushbutton2, MyValue2 appears and suddenly makes MyValue1 disappear! What is happening to MyValue1? How can I keep both MyValue1 and MyValue2 in the struct? If you know the reason, please explain it elaborately. Thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!