フィルターのクリア

How to create a loop that skips iterations?

2 ビュー (過去 30 日間)
osminbas
osminbas 2012 年 4 月 4 日
Hello,
Here is my code
for y=500:571
fileID=num2str(y);
filename=['Probe TestID ',fileID];
myFolder1='C:\';
filePattern1=fullfile(myFolder,filename)
D=xlsread(filePattern1,'E:E');
...
end
The files in 'myFilder1' are named as Probe TestID XXX but they are not always continuous (with 1 iteration), i.e, Probe TestID 500, Probe TestID 501, Probe TestID 509,....
How do I create a loop that will skip the discontinuity and read all the files without erroring out?
Thank you!

採用された回答

Walter Roberson
Walter Roberson 2012 年 4 月 4 日
for y=500:571
fileID=num2str(y);
filename=['Probe TestID ',fileID];
myFolder1='C:\';
filePattern1=fullfile(myFolder,filename)
if exists(filePattern1, 'file')
D=xlsread(filePattern1,'E:E');
else
fprintf(1, 'skipped missing file %s', filePattern1);
end
...
end
  1 件のコメント
osminbas
osminbas 2012 年 4 月 4 日
Thank you, Walter! Awesome! :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by