How can read 30 text data files in matlab ?

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 件のコメント

Daniel Dolan
Daniel Dolan 2020 年 2 月 29 日
Is there some kind of pattern to the file names?
Jalaj Gambhir
Jalaj Gambhir 2020 年 3 月 2 日
Can you tell us some different file names (whether or not they have a pattern to them) and the kind of data each file contains, in order to assist you.
Salah Djerouni
Salah Djerouni 2020 年 3 月 2 日
1.2.3.4.5.6...30
Salah Djerouni
Salah Djerouni 2020 年 3 月 2 日
each file data contain two vectors
Salah Djerouni
Salah Djerouni 2020 年 3 月 2 日
(:,1)
(:,2)

サインインしてコメントする。

回答 (1 件)

TADA
TADA 2020 年 3 月 2 日
編集済み: TADA 2020 年 3 月 2 日

0 投票

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

カテゴリ

ヘルプ センター および File ExchangeFile Operations についてさらに検索

製品

リリース

R2019b

質問済み:

2020 年 2 月 28 日

編集済み:

2020 年 3 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by