I have written two scripts which function on their own and which import data from Excel files and store it in a structure. Now I want to make my script more user friendly by implementing them into a GUI. If this works, I want to modify the second script, so that the values of some variables can be set via the GUI and does not need to be modified in the script. Sadly, I already fail in the first part.
Because the output I want to generate does not exist from the beginning, but is only generated after the script is run upon a pressing of a pushbutton, I changed the opening function and the closing function.
function simple_gui_OpeningFcn(hObject, eventdata, handles, varargin)
set( hObject, 'WindowStyle', 'modal' );
function figure1_CloseRequestFcn(hObject, eventdata, handles)
if isequal(get(hObject, 'waitstatus'), 'waiting')
The code for the pushbutton is the following, where
is one of the two scripts which should be run to import and modify the experimental data. All data is then stored in the structure "AutarkyData"
function pushbutton1(hObject, eventdata, handles)
handles.AutarkyData = AutarkyData;
According to my knowledge, upon pressing the pushbutton1 the following happens:
1. The AutarkyDataMain.m script is run
2. The structure "AutarkyData" is assigned to the handle-structure under the fieldname "AutarkyData"
3. The handly structure is globally updated
If open the GUI and press the button, the script is run as it should. But as soon as I close the GUI to receive the ouput, I get the following error message:
"Reference to non-existent field 'AutarkyData'."
I played a bit with the code and think I can narrow the source of the error.
The second script does also modify the data, but does so by assuming some "standard values" and varying other, while the first one (with which the abovehand mentionned error occurs) does import the values via a UI which alllows to select the Excel files which shall be imported.
[filenamecell, filepath] = uigetfile('*.xls;*.xlsx', 'Select Exel data file','MultiSelect', 'on');
when running the code from above with the second script, the output of the AutarkyData structure from the GUI is succesful. This leads me to believe that the problem may arise because of the "UI within the GUI", but my knowledge in Matlab is limited, so this is pure speculation.
Does anybody know where the mistake lies and has an alternative code which will work for me?
Thanks in advance