How can read 30 text data files in matlab ?

조회 수: 1 (최근 30일)
Salah Djerouni
Salah Djerouni 2020년 2월 28일
편집: TADA 2020년 3월 2일
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
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일
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