how to have indication of matlab function stopped

2 ビュー (過去 30 日間)
adi
adi 2020 年 7 月 5 日
編集済み: dipak nigam 2020 年 7 月 5 日
Hi,
is there a way to have an indication when matlab function stops?
lets say i have a function and i want to use another function in cases that the first one stopped/got stuck.
how can i do this?
thank you
  2 件のコメント
John D'Errico
John D'Errico 2020 年 7 月 5 日
What do you mean by stopped/got stuck?
Are you asking how to know when another function seems stuck in an infinite loop?
Are you asking to know when a function has terminated running due to some error condition?
adi
adi 2020 年 7 月 5 日
hi,
yes i want to know when a function has terminated running due to some error condition.
actually i work with the matlab fit function and in some curves i get the error of not being able to fit, therefore in these cases i would like to fit with another function- so i would like to have this indication so the program wont terminate.
thank you

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

回答 (1 件)

dipak nigam
dipak nigam 2020 年 7 月 5 日
編集済み: dipak nigam 2020 年 7 月 5 日
As per my understanding, you want to run another function if your present function raises an 'error' or 'fails'. You can put the statements prone to failure in a try block and call the other function in a catch block to achieve this functionality.
Here you can find the documentation for the same-
Otherwise, you can use the condition statements if your current function does not raise an error.
In the case your function just stops the execution and doesn't raises an error, i.e 'gets stuck' you can create a timer until the expected time-limit and then raise an exception/error yourself after that timer runs out. Try-catch statements can be used with timer to handle such cases.
You may get some idea here-

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by