How can i read multiples files from a directory?
2 次查看(过去 30 天)
显示 更早的评论
I have used a loop but i get only the content of the last file. Can someone help me? Thanks in advance
0 个评论
回答(1 个)
Giorgos Papakonstantinou
2015-3-10
Assuming you want to open a few files. Create a cell|filenames|. Then the loop would be like this>
filenames = {'file1.txt' 'file10.txt' 'file11.txt'};
for ii=1:length(filenames)
fid = fopen(char(filenames(ii)));
.... % here you can do textscan for example
fclose(fid);
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Export 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!