reading multiple files using importdata
37 次查看(过去 30 天)
显示 更早的评论
Hi! Wanna import data from various .txt-files. And I am wondering why the code, I'm using, is not working. Probably I did a mistake in the format of entering the file name and directory. Anybody know what to do?
if true
pth = 'C:\Users\Marcus\Documents\MATLAB\data\'; % directory of the folder, where data files are saved
liste = dir(strcat(pth,'*.txt')); % creates a list of all files in the folder directory pth
files = {liste.name}; % creates a cell array with the name of the data file
for k = 1:numel(files);
fullname = strcat(pth,files) ;
data = importdata(fullname);
end
0 个评论
回答(1 个)
michael
2016-10-3
1. you have to do the dir command before the strcat
2. you can't do the stract on the whole list, you have to do it one by one
i.e
liste = dir('*.txt');
for i=1:length(liste)
files=strcat(pth,'\',liste.name(i))
end
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Large Files and Big Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!