フィルターのクリア

Prase a sequence (of existing and not existing) folders

1 回表示 (過去 30 日間)
Alex
Alex 2011 年 8 月 15 日
Dear all, I would like to parse a sequence of folders with the below structure.
Mi.j
i=1..2 j=1...16
the problem is that a for loop will not work, as not all these folders exist. How I can skip one non existing folder the smart way?
B.R Alex

採用された回答

Fangjun Jiang
Fangjun Jiang 2011 年 8 月 15 日
help exist
EXIST('A','dir') checks only for directories.
break() can terminate a for-loop.
continue() passes control to the next iteration.
for i=1:2
for j=1:16
Folder=sprintf('M%d.%d',i,j);
if ~exist(Folder,'dir')
continue;
end
%do your stuff
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by