Error while evaluating uicontrol Callback

조회 수: 4 (최근 30일)
sermet
sermet 2015년 5월 21일
댓글: Walter Roberson 2015년 9월 20일
I created pushbutton in GUI;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName1,PathName] = uigetfile('*.xlsx','Select the excel file');
[num,txt1,raw] = xlsread(FileName1);
%when user click pushbutton then click close the "select the excel file" window following errors occur;
Error using xlsread
Filename must be a string.
Error in helmert_fig>pushbutton1_Callback (line 84)
[num,txt1,raw] = xlsread(FileName1);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in helmert_fig (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)helmert_fig('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
%how I can modify the xlsread function to supress these errors when user close the window without select any file to read?

채택된 답변

Adam
Adam 2015년 5월 21일
편집: Adam 2015년 5월 21일
if FileName1 ~= 0
[num,txt1,raw] = xlsread(FileName1);
end
Obviously you will have to also include any further code that uses those created variables inside the if statement also.
  댓글 수: 1
Walter Roberson
Walter Roberson 2015년 9월 20일
selahattin sert comments
Thank you for this answer.It is work with.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by