Filter löschen
Filter löschen

How do I generate a sequence of variable matrices from data stored in multiple .mat files?

1 Ansicht (letzte 30 Tage)
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

Akzeptierte Antwort

KSSV
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

Weitere Antworten (0)

Kategorien

Mehr zu Workspace Variables and MAT-Files finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by