首页 > 其他 > 详细

MATLAB 读子文件夹下文件

时间:2016-06-29 01:05:12      阅读:225      评论:0      收藏:0      [点我收藏+]

把符合的文件路径保存到fp中,FileType为指定文件的类型,MainPath为文件夹的路径

function Path=ReadFile(fp,MainPath,FileType)
%%%%%%%%%%%%%%
%MainPath为主路径,FileType为需要读取的文件类型
PathFileFormation=dir(MainPath);
PathNumber=numel(PathFileFormation);
for LoopPathNumber=1:PathNumber

if( isequal( PathFileFormation( LoopPathNumber ).name, ‘.‘ ) || ...
isequal( PathFileFormation( LoopPathNumber ).name, ‘..‘ )) % 如果不是目录跳过
continue;
elseif PathFileFormation( LoopPathNumber ).isdir
Path=fullfile(MainPath,PathFileFormation(LoopPathNumber).name);
Path=ReadFile(fp,Path,FileType);
else

Path=fullfile(MainPath,[‘*‘,FileType]);
images=dir(Path);
for i=1:numel(images)
fprintf(fp,‘%s\n‘,fullfile(MainPath,images(i).name));
end
break;
end

end

 

MATLAB 读子文件夹下文件

原文:http://www.cnblogs.com/matrix314/p/5625361.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!