フィルターのクリア

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 Center および File ExchangeFile Operations についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by