how to skip an error inside a loop?
1 回表示 (過去 30 日間)
古いコメントを表示
Zeynab Mousavikhamene
2019 年 8 月 15 日
編集済み: Zeynab Mousavikhamene
2019 年 8 月 16 日
I have a loop which reads from a structure. The pattern might change in the loop. Sometimes I need to call the element that I want by this structure: 1) data.timepoints(6).cells{89, 1}{2, 1}{2, 1}(3) and sometimes this strucutre gives error: "Brace indexing is not supported for variables of this type." so that I have to change to the: 2) data.timepoints(6).cells{90, 1}{2, 1} (3)
Is there a way to add "if conditional": if you get error with the 1st arrangement do the second arrangement.
0 件のコメント
採用された回答
Walter Roberson
2019 年 8 月 15 日
try
x = data.timepoints(6).cells{89, 1}{2, 1}{2, 1}(3);
catch ME
try
x = data.timepoints(6).cells{90, 1}{2, 1}(3);
catch MEME
%neither worked
end
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!