Effacer les filtres
Effacer les filtres

How to load only a subset of .dat files into MATLAB?

3 vues (au cours des 30 derniers jours)
Bianca Elena Ivanof
Bianca Elena Ivanof le 23 Juin 2016
Hello,
I am currently trying to load only a subset of files (i.e. files 1 to 6) into MATLAB using the following piece of code
cd('D:\Documents\Goldsmiths\Experiments\Curiosity x agency\Data pilot')
files=dir(fullfile('D:\Documents\Goldsmiths\Experiments\Curiosity x agency\Data pilot','_*.dat'));
for k=1:numel(files)
load(files(k).name);
end
This code works, in that it loads all files that end in .dat in the specified directory. But I only want files 1:6. I tried doing it this way
cd('D:\Documents\Goldsmiths\Experiments\Curiosity x agency\Data pilot')
files=dir(fullfile('D:\Documents\Goldsmiths\Experiments\Curiosity x agency\Data pilot','001*.dat','002*.dat','003*.dat','004*.dat','005*.dat','006*.dat'));
for k=1:numel(files)
load(files(k).name);
end
but it didn't get me the expected results.
Could you please be so kind as to help me?

Réponses (1)

Thorsten
Thorsten le 23 Juin 2016
for k=1:6
load(files(k).name);
end

Catégories

En savoir plus sur File Operations 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