MATLAB: Using pushbutton to load file in GUI

guiguideload

I am new to creating a GUI. I am using guide, and have a push button that opens a uigetfile dialog box using the code:
[filename1,filepath1]=uigetfile({'*.*','All Files'},...
'Select Data File 1');
cd(filepath1);
rawdata1=load(filename1);
It seems to work. It opens, I select a file and hit ok, but there is no "rawdata1" in the matlab workspace. Where is this file stored?

Best Answer

do this:
rawdata1=load([filepath1 filename1]);
GUI does not pass files to the workspace. You have to use the rawdata1 variable withing the function. You can make it semi-global by doing handles.rawdata1=load([filepath1 filename1]); and then access it the same way. If you leave the current function you must save changes to your handles.rawdata1 by typing this:
guidata(hObject, handles);
before you exit the function. If you want to copy the variable to the workspace, see my answer here: http://www.mathworks.com/matlabcentral/answers/19529-how-to-pass-arrays-to-and-from-a-gui