How to set continue function?

8 ビュー (過去 30 日間)
Arif
Arif 2024 年 2 月 13 日
コメント済み: Arif 2024 年 2 月 14 日
What the function that i need to set code-step which will decide wheter my coding continue to run or stop.
i want create a code after rows named 'checkperiod'. If the result of checkperiod is true(1), i want it to stop my running code and send me a message "Make the structure bigger" and this message can be string-variable. If the resut of checkperiod is false(0), then let it continue but still send me the message by string variable that contains "fullfill".
Thank for attention
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2024 年 2 月 13 日
編集済み: Dyuman Joshi 2024 年 2 月 13 日
The use of logical() in line 157 is redudant. You can remove it.
Also, you can use deal to assign (the same) inputs to different outputs.

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

採用された回答

Aquatris
Aquatris 2024 年 2 月 13 日
You are looking for assert() function.
When you condition is satsified
assert(1>0,'STOPPED THE CODE!')
fprintf('Code continues!')
Code continues!
When your condition is not satisfied;
assert(1<0,'STOPPED THE CODE!')
Error using assert
STOPPED THE CODE!
fprintf('Code continues!')
  4 件のコメント
Aquatris
Aquatris 2024 年 2 月 13 日
assert function stops the code, thats why you do not see the 'Code continues!' text when the assert condition is false.
Arif
Arif 2024 年 2 月 14 日
thanks

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

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2024 年 2 月 13 日
doc continue
doc break
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2024 年 2 月 13 日
Also, doc return

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by