MATLAB: Loading .mat file from within GUI not doing anything?!

load

Hi,
I have made a simple concept GUI to test populating a drop down menu based on the .mat files in a directory, and then loading the selected .mat file.
My code (attached – change the directory to where you save it…) is notdoing anything when I try to load the .mat file.
On the other hand if I type in the command window:
handles.Selection = 'Data2.mat'
load(handles.Selection)
It loads fine… Why is this? I'm lost!
Thanks,
Matt

Best Answer

There is no such thing as " the workspace"... you might be thinking of the base workspace when you say that, but in fact every function and callback has its own workspace. And load is correctly loading into whichever workspace it is called from.
If you want to understand what MATLAB is doing, and how to pass your data between workspaces, then it is time do some reading:
TIP: avoid globals, assignin, evalin, etc.