I looked at some tutorial videos, other questions, and this link here:
The section titled, "How can I share data between callback functions in my GUI(s)?" is quite nice, but I am confused about this part:
Since variables passed in to MATLAB functions are "pass by value" and not "pass by reference" if you change any of the variables, you are only changing the local copy. If you change any of the variables attached as members of the handle structure, and you want to retain these changed values in the calling function, you will have to return the handles structure as an output of your function, and accept it in your calling function, or else use the guidata() function. Otherwise changes you make to the handles structure variables are only local and will not survive once the function has returned.
I don't quite get it. How do I update the handles structure in a callback so that all subsequent callbacks see it? If I write in one of my callbacks
handles.MyVar = MyVar;
then will every callback that comes later be able to "see" handles.MyVar?
In my concrete example, I have a button that loads a .mat file with variables of interest. I then want to work with one of those variables in a later callback, which is from another push-button.
Best Answer