Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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

Réponse acceptée

KSSV
KSSV le 10 Mar 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

Plus de réponses (0)

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by