How can I fix Error using files=dir command
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (3)
Steven Lord
el 16 de Nov. de 2018
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 comentarios
Image Analyst
el 17 de Nov. de 2018
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 comentarios
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!