Run a script in each subfolders and extract results for each subfolders in another folder

2 visualizzazioni (ultimi 30 giorni)
I have a 'folder' which contains several subfolders for each sea wave height and period :
-subfolder(1:n) : 'Hs(0.25:0.5:5.25) Tp(2.5:1:9.5)'
example: subfolder(1) : 'Hs(0:25) Tp(2.5)'
.....
subfolder(4) : 'Hs(0.75) Tp(2.5)'
.....
subfolder(7): 'Hs(1.25) Tp(3.5)'
subfolder(8) : 'Hs(1.25) Tp(4.5)'
....
subfolder(11) : 'Hs(1.25) Tp(9.5)'
....
subfolder(end): 'Hs(5.25) Tp(9.5)'
I have several subfolders which are the combination between different Hs and different Tp. In each subfolder there is a 'file.mat'. I have to run the same matlab code in each subfolder to extract results from 'file.mat' and save them in another folder.
I would like to get in each subfolder through a code which can distinguish the several Hs and Tp cases (double for cycle) and run a code in order to extract results from 'file.mat' and extrapolate data in another folder.
Please help, I am a beginner.

Risposta accettata

Jan
Jan il 27 Feb 2021
FileList = dir(fullfile(Folder, '**', 'file.mat'));
for iFile = 1:numel(FileList)
SubFolder = FileList(iFile).folder;
Data = load(fullfile(Folder, FileList(iFile).name));
... Run your code with this data
end

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by