Where is the difference between these two lines?
조회 수: 1 (최근 30일)
이전 댓글 표시
Check out the copy-pasta from my command window in matlab at the end.
I swapped between both lines via the arrow key. And reexecuting the same line gave the same result
I copied both lines into 2 different txt files to have notepad++ compare them, and the only difference it found was in the 'E'
So I tried both lines again, this time with a replaced E (made sure I didnt accidently add any accents or whatever).
I replaced the isfolder() with exist() and got the same weird results ( a 7 instead of logical 1).
But the result is still the same.
What is going on here?
K>> isfolder('E:\GIT\loop-test')
ans =
logical
0
K>> isfolder('E:\GIT\loop-test')
ans =
logical
1
K>>
K>> isfolder('E:\GIT\loop-test')
ans =
logical
0
K>>
K>> isfolder('E:\GIT\loop-test')
ans =
logical
0
K>>
K>> isfolder('E:\GIT\loop-test')
ans =
logical
0
K>>
K>> isfolder('E:\GIT\loop-test')
ans =
logical
1
K>> isfolder('E:\GIT\loop-test')
ans =
logical
1
K>> isfolder('E:\GIT\loop-test')
ans =
logical
0
>> isfolder('E:\GIT\loop-test')
ans =
logical
0
>> isfolder('E:\GIT\loop-test')
ans =
logical
0
>> isfolder('E:\GIT\loop-test')
ans =
logical
0
>> isfolder('E:\GIT\loop-test')
ans =
logical
0
>> isfolder('E:\GIT\loop-test')
ans =
logical
1
>> isfolder('E:\GIT\loop-test')
ans =
logical
1
>> isfolder('E:\GIT\loop-test')
ans =
logical
1
>> isfolder('E:\GIT\loop-test')
ans =
logical
0
>> isfolder('E:\GIT\loop-test')
ans =
logical
0
댓글 수: 6
Guillaume
2019년 6월 24일
편집: Guillaume
2019년 6월 24일
An easier way to get the path of any object on Windows, is to press shift and right click on the object in explorer. In the extended context menu that pops up, select copy as path. This won't have any left-to-right or right-to-left control characters as well.
채택된 답변
추가 답변 (1개)
Matt J
2019년 6월 24일
편집: Matt J
2019년 6월 24일
My guess is that you have called the isfolder command with two different versions of the input, but with hidden characters or accents that make them look the same. Because the differences are not visible, you are unable to know which version you are executing when you use the arrow keys to scroll through the command history.
댓글 수: 4
Rik
2019년 6월 24일
편집: Rik
2019년 6월 24일
The different character are still in the post (? for forum Unicode support). I copied the text from the post for both the true and false output.
T='E:\GIT\loop-test';
F='E:\GIT\loop-test';
double(T(1:3))
double(F(1:3))
Valid paths in Windows don't have a lot of limitations (link), but you're probably limited to 32-255 (excluding special characters). "The current code page" is likely something like cp1252, but apparently could support more chars. If you're certain about the code page in use on your system, you could filter all other chars away before calling isfolder.
Guillaume
2019년 6월 24일
So F starts with unicode 202A, which is an invisible control character and indeed may be taken into account by the OS (nothing to do with matlab here, it's the OS that parses the path ultimately).
We can't explain why that character got there, maybe see this, but whenever you see this sort of behaviour suspect invisible characters or characters that look the same but are actually different.
Hence why I asked initially the conversion to double.
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!