batch processing (automating code processing)

5 Ansichten (letzte 30 Tage)
maryam al labbad
maryam al labbad am 2 Nov. 2020
Hi all,
I have a question about running a code on multiple datasets. I have seen many examples and methods, but unfortunetly, they did not work for me.
I have over 500 data sets, all have same structure of data but different numbers (arranged in sruct.array) so they are already in .mat form.
Those .mat files are stored on my computer as follow :mainfolder > 5 subfolder > N number of subsubfolder > 15 .mat files
Thus, for each subsusbfolder, there is 15 .mat files.
So, basically I want to process those .mat files by calling a function on all of those data sets automatically, but not really sure how to do so especially that I need a for loop to navigate my subfolders and subsubfolders to reach to the .mat files.
Any help would be appreciated.

Akzeptierte Antwort

Mario Malic
Mario Malic am 2 Nov. 2020
Bearbeitet: Mario Malic am 2 Nov. 2020
This will give you the structure containing all .mat files.
File_Struct = dir('**/*.mat');
Edit:
Use name and folder to get the full path to each .mat file.
File_Struct = dir(fullfile(myFolder, '**/*.mat'))
File_Path = cell(size(File_Struct,1), 1);
for ii = 1 : 1 : size (File_Struct,1)
File_Path {ii} = fullfile(File_Struct(ii).folder, File_Struct(ii).name);
fprintf(1, 'Now reading %s\n', File_Path {ii});
load(File_Path {ii}); %this is changed
data=myfunc1(data)% calling my function1
data=myfunc2(data)% calling my function2
Processed_Data(ii).Value = data; % structure
end
  23 Kommentare
Mario Malic
Mario Malic am 3 Nov. 2020
This time, I'll suggest you to read the documentation on the functions used in these two lines. I want to help, but if I'm going to answer every question you might have, it won't lead you further ahead.
So, read up on save and fullfile.
What value does fullfile return? What input arguments save function takes? Once you learn that, you'll be able to solve your problem. You were on the right track with the answer - does it deal with .name thing?
maryam al labbad
maryam al labbad am 3 Nov. 2020
Great! thanks

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by