How can I fix Error using files=dir command
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (3)
Steven Lord
le 16 Nov 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 commentaires
Image Analyst
le 17 Nov 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 commentaires
Voir également
Catégories
En savoir plus sur File Operations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!