For Looping to import .mat files

1 vue (au cours des 30 derniers jours)
Jake Bowd
Jake Bowd le 23 Jan 2020
Commenté : Stephen23 le 23 Jan 2020
Hi All,
I have a folder that I want to import all .mat files in from. So far I have got the following which identifies the amount of .mat files there are, however I am unsure how to import the .mat data in after this.
cd('D:\Leuven_Visit\Workflow\Matlab\Results\HV_NL');
procfiles=dir('*.mat');
nparticipants=size(procfiles,1);
for i=1:nparticipants
end

Réponse acceptée

Bhaskar R
Bhaskar R le 23 Jan 2020
Modifié(e) : Bhaskar R le 23 Jan 2020
procfiles = dir('D:\Leuven_Visit\Workflow\Matlab\Results\HV_NL\*.mat');% cd is not recommended
for iMat= 1:size(procfiles, 1)
load(fullfile(procfiles(iMat).folder, procfiles(iMat).name));
end
  1 commentaire
Stephen23
Stephen23 le 23 Jan 2020
Even better to load into an output variable (which is a scalar structure):
S = load(...)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Low-Level File I/O dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by