I am trying to read several tables within the same directory (currently in .txt format). The file names are as follows:
0.0.txt
0.2.txt
0.4.txt
and so on until 2.0.txt
How can I implement the loop feature to tell MATLAB to read all the files starting from 0.0.txt up to 2.0.txt with the value before '.txt' increasing by 0.2 each time?

 채택된 답변

KSSV
KSSV 2023년 1월 24일

0 개 추천

txtFiles = dir('*.txt') ;
N = length(txtFiles) ;
for i = 1:N
T = readtable(txtFiles(i).name)
end

댓글 수: 1

And if you want to keep all of the imported data:
S = dir('*.txt');
for k = 1:numel(S)
S(k).data = readtable(S(k).name);
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2023년 1월 24일

댓글:

2023년 1월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by