Read Multiple Files with While Loop
조회 수: 1 (최근 30일)
이전 댓글 표시
I have about 20 files that I need to read and manipualte data. How would I write a while loop so that it will read the file, extract data, then continue to read the next file, etc. ?
댓글 수: 2
Walter Roberson
2022년 9월 20일
Is there a particular reason to use a while loop instead of a for loop?
Stephen23
2022년 9월 20일
"How would I write a while loop so that it will read the file, extract data, then continue to read the next file, etc. ?"
The standard approach is to use a FOR loop:
답변 (1개)
Chunru
2022년 9월 20일
fn = dir("*.dat"); % or your file name pattern
for i=1:length(fn)
fn_c = fn(i).name % current filename to be processed
% do processing for fn_c
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!