stop, record and continue a loop function

1 回表示 (過去 30 日間)
Fadzli
Fadzli 2017 年 5 月 22 日
コメント済み: Fadzli 2017 年 5 月 26 日
Hi,
I have problem in running a for loop function. Let say I'm running 5 loop function, but at 3rd loop, there was an error and I have to stop it manually (press Ctrl+C). Then unfortunately all the previous 2 results were gone. So how can I stop the function without missing the results and at the same time, automatically continue to the next loop? Thanks
  2 件のコメント
Stephen23
Stephen23 2017 年 5 月 22 日
@Fadzli: Some options:
  • save intermediate data
  • use try and catch to avoid errors
  • write code to be robust for all known cases, incl. edge-cases.
  • record and re-run failed cases only.
  • ...
What you use depends on your data and your workflow.
Fadzli
Fadzli 2017 年 5 月 26 日
Thanks @Stephen Cobeldick, Will try to look for the best option on my case. Also looking for 'break' function whether it is suitable to be used in my case.

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

採用された回答

KSSV
KSSV 2017 年 5 月 22 日
Check try and Catch
  1 件のコメント
Fadzli
Fadzli 2017 年 5 月 26 日
Thanks @KSSV, will try to use that function. But any details on how to use it is really appreciated...

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

その他の回答 (0 件)

カテゴリ

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