Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
Bianca Elena Ivanof
Bianca Elena Ivanof el 23 de Jun. de 2016
Comentada: Bianca Elena Ivanof el 26 de Jun. de 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?

Respuestas (1)

Thorsten
Thorsten el 23 de Jun. de 2016
for k=1:6
load(files(k).name);
end

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by