function pushbutton1_Callback(hObject, eventdata, handles)
[FileName,~]=uigetfile('*.mat','Get File')
handles = load(FileName)
guidata(hObject,handles)
This is a really bad idea. Do not overwrite the handles struct.
Consider the path name also, because a user can select another folder in the uigetfile dialog:
[FileName, FilePath] = uigetfile('*.mat', 'Get File');
if ~ischar(FileName)
disp('User canceled the file selection');
return;
end
handles.FileData = load(fullfile(PathName, FileName))
guidata(hObject, handles);
This is a questionable idea also:
function edit1_Callback(hObject, eventdata, handles)
handles.geneName = get(hObject,'String');
guidata(hObject,handles);
Remember that the "handles" in the input argument is the contents of the struct conserved at the time, when the callback has been defined - or did GUIDE use a smart mechanism to update the input now? Safer and/or perhaps the only valid method:
function edit1_Callback(hObject, eventdata, handlesFronInput)
handles = guidata(hObject);
handles.geneName = get(hObject,'String');
Searching for tags can be time consuming and tags need not be unique, e.g. if you open multiple instances of the dialog. Prefer using the handles:
hist(handkles.axes2, varYY1, XX);
title(handles.axes2, 'varYY1');
This is safer also, when the user clicks in GUI elements during the code runs. Setting the active axes by the axes() command is overridden, when the user clicks on another axes.
Best Answer