Loading multiple files into matlab
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Joel Schelander
il 22 Apr 2021
Risposto: Shadaab Siddiqie
il 27 Apr 2021
I have 36 different .mat files in a folder: AAG1,AAG2,AAG3...AAG36. Each file only contain one variable called 'GUD'
I want to load all the files and naming the variables so I can distinguish between them, like naming them AAG1,AAG2 in the script. I have tried the following:
But I do not know how I can seperate the variables from each other
filenames = {'AAG','AAG2','AAG3'};
for kk = 1:numel(filenames)
S = load(filenames{kk})
end
0 Commenti
Risposta accettata
Shadaab Siddiqie
il 27 Apr 2021
From my understanding you want to load data form all the mat files into the workspace and assign it into different variables. In your case since all the 'GUD' are structs, we can create a list of cells and add each value into the list after converting them into cell. Here is the code which might help you.
filenames = {'AAG1','AAG2','AAG3'};
AAG = {};
for kk = 1:numel(filenames)
AAG(kk) = struct2cell(load(filenames{kk}))
end
Then for example you can access the values of data in 'AAG19.mat' like AAG(19) .
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Whos in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!