Read Sequence text files in Matlab
1 次查看(过去 30 天)
显示 更早的评论
Hello everybody , I want to read more than one text file in Matlab with loop , this files not in sequence names same this 'GSM-2_2002095-2002120_0021_UTCSR_0060_0005' 'GSM-2_2002123-2002137_0012_UTCSR_0060_0005', How can i do it ?
0 个评论
采纳的回答
harjeet singh
2016-1-17
编辑:Walter Roberson
2016-1-17
try to use this code, do read file with fopen using file_path in the loop
folder_name='ABC';
files=dir(folder_name);
for i=3:length(files)
file_name=files(i).name;
file_path=strcat(folder_name,'\',file_name);
end
2 个评论
Walter Roberson
2016-1-17
Please learn to use fullfile() as we do not assume that everyone is using MS Windows (OS-X and Linux use / not \ )
harjeet singh
2016-1-17
thanks @walter so the above command will be like
file_path=fullfile(folder_name,file_name);
更多回答(1 个)
Hussein Mohasseb
2016-1-17
1 个评论
harjeet singh
2016-1-17
folder_name='test';
files=dir(folder_name);
for i=3:length(files)
file_name=files(i).name;
file_path=fullfile(folder_name,file_name);
fid=fopen(file_path);
c=fread(fid,inf,'*char')
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!