How to exclude some files while load a set of files using a loop?

1 回表示 (過去 30 日間)
aneps
aneps 2014 年 6 月 24 日
回答済み: Yujia Hu 2014 年 6 月 24 日
I am loading a set of files using loop as follows:
for k=1:10
A{k} = load(['E:/MatlabData/File',num2str(k),'.asc']);
end
As it is clear in the loop, I have a set of 10 files. I want to exclude some files, for example, I don't want to load 5th one and 7th one... How can I exclude those files from the loop? This will be more complicated for me if I have 15 files and have to exclude 3, 4, 5 and 8th file! Any solution?

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 6 月 24 日
for k=setdiff(1:10,[5 7])

その他の回答 (1 件)

Yujia Hu
Yujia Hu 2014 年 6 月 24 日
Are you asking how to loop for a set of numbers? Like this:
k=[1,2,6,7,9:15];
for j = k
A{k} = j
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by