필터 지우기
필터 지우기

i want to create an error msg in matlab gui

조회 수: 2 (최근 30일)
partha das
partha das 2011년 7월 13일
I want to run a program where a excel file will be taken as input and i want that if the excel file is not find there should be an error msg. how can i create that type of error msg box. here file name is stored in a variable named a. please help me. thank you in advance..
  댓글 수: 1
partha das
partha das 2011년 7월 13일
plz tell me the condition for the error msg.

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

채택된 답변

Friedrich
Friedrich 2011년 7월 13일
Hi,
You have to use the exist function. If the Excel file is not on the MATLAB path you will need the absolut path to it. And than do
if exist(a,'file') ~= 2
msgbox('File Not found','Error','Error');
else
%file is there, do something with it
end
Where a should look like
a = 'C:\folder_with_file\name_of_file.xls'
a =
C:\folder_with_file\name_of_file.xls

추가 답변 (1개)

Chirag Gupta
Chirag Gupta 2011년 7월 13일
The previous answer seems to work. What are the contents of the variable? Is the variable a cell?
filename = 'MyTest1.xls'
if (~exist(filename,'file'))
msgbox('File Not Found','Error','Error');
end
What is the error if any that you are getting? Note that if the variable filename is a cell, you will need to pass the name explicitly like:
exist(filename{1},'file')
  댓글 수: 6
Friedrich
Friedrich 2011년 7월 13일
it works fine for me. please post your code and the content of the variable a
partha das
partha das 2011년 7월 13일
thank you.. very much sir..

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

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by