Skip data files while reading input and writing output in matlab code
显示 更早的评论
I use matlab code to read several files and write output in the following way:
n=202;
for idx = 0:n
infilename = sprintf('pt%d.txt',idx);
outname = sprintf('out%d.txt',idx);
Now if some arbitrary data files are missing e.g. pt20.txt, pt50.txt ,etc then the code is terminated. I would like to modify the code in a way that if some data files are not found then the code would skip them and proceed to reading/writing the next available data file.
Thank you.
回答(1 个)
Azzi Abdelmalek
2015-6-17
编辑:Azzi Abdelmalek
2015-6-17
infilename = sprintf('pt%d.txt',idx);
if exist(infilename)
%do
end
2 个评论
Sabbir
2015-6-17
编辑:Walter Roberson
2015-6-18
Azzi Abdelmalek
2015-6-17
yes, it was just a typo
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!