Using fullfile for multiple file names

Hi,
I am trying to select 3 files (con_001.img, con_002.img, con_003.img) and store them in a 3x1 cell named P. I have specified C={'con_001.img','con_002.img','con_003.img'}. I first did the following:
for f=1:length(C)
P = cell(f,1);
P{f,1} = spm_select('FPList', fullfile(data_path),sprintf('%s',cell2mat(C(1,f))));
end
Of course the above gave me P containing only con_003.img and not the other two images. I then tried:
P{1:f,1} = spm_select('FPList', fullfile(data_path), sprintf('%s',cell2mat(C(1,f))));
This time it didn't work at all.
Could some one please help?

 採用された回答

Jan
Jan 2014 年 4 月 6 日

0 投票

C = {'con_001.img','con_002.img','con_003.img'}
P = cell(1, length(C)); % Before the loop
for f = 1:length(C)
P{f} = spm_select('FPList', fullfile(data_path, C{f}));
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeFilename Construction についてさらに検索

製品

タグ

質問済み:

2014 年 4 月 6 日

回答済み:

Jan
2014 年 4 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by