Running files in folders in loop.

3 Ansichten (letzte 30 Tage)
Yashvardhan Bhati
Yashvardhan Bhati am 20 Okt. 2022
Beantwortet: Benjamin Kraus am 21 Okt. 2022
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
.
.

Antworten (1)

Benjamin Kraus
Benjamin Kraus am 21 Okt. 2022
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.

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by