How do I generate a sequence of variable matrices from data stored in multiple .mat files?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Anas Deiranieh's
am 10 Mär. 2017
Beantwortet: KSSV
am 10 Mär. 2017
I have a number of similarly named files each with a differing number of columns and two variables, height & weight.
Group1.mat,. . . ,GroupN.mat
How do I grab each file and separate the variables into their own values?
Height1,...,HeightN Weight1,...,WeightN
I tried this:
FileTotal = dir('*.mat');
i = length(FileTotal);
for k = 1:i
Height{k} = FileTotal.height
Weight{k} = FileTotal.weight
end
I've tried other things as well. No luck
0 Kommentare
Akzeptierte Antwort
KSSV
am 10 Mär. 2017
Files = dir('*.mat'); % all mat files in the folder
N = length(Files); % total number of files
Height = cell(N,1) ; % initialize heights
Weight = cell(N,1) ; % initialize weights
for k = 1:N % loop for each file
load (Files(k).name) % load the file
Height{k} = height ;
Weight{k} = weight ;
end
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!