필터 지우기
필터 지우기

Read Multiple Files with While Loop

조회 수: 1 (최근 30일)
Daniella Chait
Daniella Chait 2022년 9월 20일
댓글: Stephen23 2022년 9월 20일
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
Walter Roberson 2022년 9월 20일
Is there a particular reason to use a while loop instead of a for loop?
Stephen23
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
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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by