How can read 30 text data files in matlab ?

1 次查看(过去 30 天)
I have 30 text data file ,how can read and take from each data text the all value in first column and all data in second column .
  5 个评论

请先登录,再进行评论。

回答(1 个)

TADA
TADA 2020-3-2
编辑:TADA 2020-3-2
you can alwsay put all of them in a single directory, then use dir to get all file names and iterate through all of them:
path = 'whatever';
files = dir(path);
% get rid of subdirectories and the likes of '.' and '..'
files = files(~[files.isdir])
data = table();
for i = 1:numel(files)
currFile = files(i);
t = readtable(fullfile(path, currFile.name));
findex = ['f', num2str(i)];
data(:, {[findex, '_1st'], [findex, '_2nd']}) = t(:, 1:2);
end

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by