Stop simulation in Matlab Fctn block

How can I stop simulation inside the ML Fctn block before it reach the end of the simulation time?
Thanks.

 採用された回答

Mischa Kim
Mischa Kim 2014 年 4 月 21 日
編集済み: Mischa Kim 2014 年 4 月 21 日

0 投票

Use the Stop Simulation block. When the input for the block (e.g. output of your MATLAB Function block) goes to non-zero, the sim stops.

2 件のコメント

William
William 2014 年 4 月 21 日
I know how to use this block. If my simulation time is set to 100 sec, can I set the conditon in the ML Fctn block that the time to be equal to the end time? (stop the execution prematurely).
Mischa Kim
Mischa Kim 2014 年 4 月 21 日
編集済み: Mischa Kim 2014 年 4 月 21 日
Sure, you can. If it is a simple "stop at a certain time" logic you can do without at MATLAB function (see model below from documentation). The sim stops at t = 10 sec, provided that the simulation time is greater or equal to 10 seconds.
If you need to use a MATLAB function please post more detailed info on what you are trying to implement.

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

その他の回答 (1 件)

ozgun gunay
ozgun gunay 2018 年 7 月 26 日

0 投票

"Stop Simulation" block exits with exit(1) in generated code. This means there is a error for OS. Is there another way ending simulation without without exit(1).

カテゴリ

ヘルプ センター および File ExchangeGeneral Applications についてさらに検索

質問済み:

2014 年 4 月 21 日

回答済み:

2018 年 7 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by