I'm using an older version of Matlab – R2009b. In my callbacks, I often call something like:
set(handles.tag1,'Value',5)guidata(hObject,handles); % ^This seems unnecessary because I'm accessing the handle to tag1 directly
According to current documentation, I should follow this up with guidata, but I haven't identified a place where this actually matters. I think I'm bypassing the need to call guidata because I'm setting the handle directly.
I think this wouldn't be the case in a later version of matlab, in which handles is a complete structure. In the newest version of matlab I'd write this:
handles.tag1.Value = 5;guidata(hObject,handles); % ^Now necessary because the handles structure is contained in this workspace
Now, the changed value to handles.tag1.Value only affects the current workspace (inside my callback) unless I either make handles an output of the callback or call guidata. I'm new to making GUIs with guide so I just want to make sure I understand these functions correctly. Can someone confirm my understanding is correct, or explain what's really going on?
Thank you.
Best Answer