How do I stop a simulation from within an S-function?
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 27 Giu 2009
Modificato: MathWorks Support Team
il 17 Nov 2021
How do I stop a simulation from within an S-function?
For example, I am attempting to stop a running simulation from within my S-Function, and I do not want to add a stop block. Is there any way I can stop the simulation in the same way as pressing the stop toolbar button but from within my code?
Risposta accettata
MathWorks Support Team
il 12 Ott 2021
Modificato: MathWorks Support Team
il 17 Nov 2021
There are several ways to stop a simulation from within an S-function:
1) For MATLAB file S-functions you can use the command:
set_param(bdroot, 'SimulationCommand', 'stop');
For Simulink 4.0 (R12) and above you can use the following on C-MEX S-functions:
1) You can do a 'mexCallMatlab' with the SET_PARAM command with the same input arguments mentioned above for MATLAB file S-functions.
2) You can use the macro ssSetStopRequested, which will allow you to stop a simulation from within your S-function (you will have to set the simulation flag in this macro to not zero). For more information on this function please see pg. 10-187 of the Writing S-function Guide. The online version of this Guide can be found at:
https://www.mathworks.com/help/simulink/sfg/sssetstoprequested.html
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Simulink Coder in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!