Running files in folders in loop.

조회 수: 3 (최근 30일)
Yashvardhan Bhati
Yashvardhan Bhati 2022년 10월 20일
답변: Benjamin Kraus 2022년 10월 21일
I have multiple folders numbered in sequence 9D-15D and inside each folder is ther is another folder numbered in sequence S_1 to S_15 and inside each folder there are files which i would read using the matlab code which i have and save data to that folder named with S_$ and do that for all the folders present and in $D folders. I can do that in other coding language but not sure how to preceed in matlab. So if you guide or tell me where to look for it would be very helpful.
9D
S_1
%Files to read using matlab code and save data
S_2
.
.
.
S_15
10D
S_1
.
.

답변 (1개)

Benjamin Kraus
Benjamin Kraus 2022년 10월 21일
You can use the dir command to get a list of the files/folders.
d = dir('**');
Once you have the list, you can loop through them to read your data and write your desired output.
You may also find the fullfile, fileparts, filesep, and exist helper functions handy when processing files like this.
You didn't specify the format of the data in the files, or the desired output format, so if you need more assitance with actually reading and writing the files, you will need to provide more specifics.

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by