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

1 次查看(过去 30 天)
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.

采纳的回答

Jan
Jan 2021-2-27
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by