How can I fix Error using files=dir command
조회 수: 7 (최근 30일)
이전 댓글 표시
I upgraded MATLAB 2014 to 2018.
When I run the code, I get an error . please advise how ot fix this error.
This code (makeMaxProjections) helps me to run all the image files (either TIF or czi) in that directory.
>> makeMaxProjections('*', '.czi')
Error using dir
Characters adjacent to a ** wildcard must be file separators.
Error in makeMaxProjections (line 28)
files=dir(['*' fileString '*' ending]);
Please help me to fix the line 28 to run this cod ein 2018 version.
files=dir(['*' fileString '*' ending]);
댓글 수: 0
답변 (3개)
Steven Lord
2018년 11월 16일
In release R2016b we enhanced dir to be able to search recursively if the filename included two asterisks adjacent to one another. I suspect fileString is empty (or begins and/or ends with an asterisk) on that line of code. In that case, you'll probably want to modify your code to take advantage of this functionality as shown in the "Find Files in Subfolders" example on the dir documentation page.
댓글 수: 0
Image Analyst
2018년 11월 17일
Try this:
% Make sure ending starts with a dot.
if ending(1) ~= '.'
ending = ['.', ending]
end
if isempty(fileString)
filePattern = sprintf('*%s', ending)
else
filePattern = sprintf('*%s*%s', fileString, ending)
end
files=dir(filePattern)
댓글 수: 0
참고 항목
카테고리
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!