Matlab doesn't see a file

I am in the same directory, it collects it in a dir, but exist shows 0 and I can't open it.

댓글 수: 2

Tom
Tom 2015년 6월 10일
편집: Tom 2015년 6월 10일
Actually, that was just a highlighting issue. I have both files, one with a y, one without, and it only sees the one without. Updated to show this clearly. Note it also see the version with - Copy in it so it's not a length issue.
Tom
Tom 2015년 6월 10일
Also, matlab v2013 was seeing this file right before I upgraded today.

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

답변 (4개)

Walter Roberson
Walter Roberson 2015년 6월 11일

1 개 추천

There could be non-printing characters in the name.
dinfo = dir('*.xlsx');
for K = 1 : length(dinfo)
thisfile = dinfo(K).name;
disp(thisfile); %as string
disp(thisfile + 0); %as bytes
r = exist(thisfile);
if r > 0
fprintf('File exists, type %d\n', r);
else
fprintf('File does not exist??\n');
end
end
Joseph Cheng
Joseph Cheng 2015년 6월 10일
편집: Joseph Cheng 2015년 6월 10일

0 개 추천

Thats because the file doesn't have a y at the end. Clearly the file shown using dir is
TEMPOgratingEfficienc.xlsx
and your exist is looking for TEMPOgratingEfficiency.xlsx

댓글 수: 2

Tom
Tom 2015년 6월 10일
Sorry, that was a debug step and I didn't show the actually file. Updated the image to show the issue.
I'd say update the picture to show both. I see the file now as it partially cut of under the TEMPOgratingEfficiency - Copy.xlsx. Are you able to put the full path such as
exist('c:\temporary\thefileimlookingat.xls')

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

Kelly Kearney
Kelly Kearney 2015년 6월 10일

0 개 추천

In your exist call, you refer to the file as TEMPOgratingEfficiency.xlsx, while the dir list shows TEMPOgratingEfficienc.xlsx. Note the missing y in the latter.

댓글 수: 1

Tom
Tom 2015년 6월 10일
Sorry, that was a debug step and I didn't show the actually file. Updated the image to show the issue.

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

Image Analyst
Image Analyst 2015년 6월 11일

0 개 추천

Like the editor recommends, try using the 'file' option in exist(). And like Joseph said, update your screenshot. And attach the "invisible" file so we can check it on our computers.

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

태그

질문:

Tom
2015년 6월 10일

답변:

2015년 6월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by