フィルターのクリア

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

3 ビュー (過去 30 日間)
Bianca Elena Ivanof
Bianca Elena Ivanof 2016 年 6 月 23 日
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?

回答 (1 件)

Thorsten
Thorsten 2016 年 6 月 23 日
for k=1:6
load(files(k).name);
end

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by