Borrar filtros
Borrar filtros

I cannot evaluate "pauseFcn" callback by using "sim" command

14 visualizaciones (últimos 30 días)
Burak Bayca
Burak Bayca el 18 de Abr. de 2024
Movida: Fangjun Jiang el 7 de Jun. de 2024 a las 18:09
Hello, I'm having issues with Simulink callbacks. I'm using MATLAB 2019a.
I have a Simulink model. I am adding a listener to an output of that model by using startFcn callback. I am expecting the model to pause when the output takes a specific value. I am implementing this algorithm inside the listener's callback function.
When I try this from Simulink by using "Run" button, the results are as expected, i.e., model pauses and the calculations are done within the "pauseFcn". But when I use "sim('myModel')" command in MATLAB, Simulink does not evaluate the pauseFcn even if the condition is triggered.
In addition, I traced the callbacks from command window. I see that, when I use 'Run' button, pauseFcn callback is triggered properly and commands in it are evaluated. However, when I use sim command, I see that pauseFcn callback is not triggered.
What should I do to make the model work corretly with sim command? Is this a bug?
  1 comentario
Federico Toso
Federico Toso el 7 de Jun. de 2024 a las 15:40
Movida: Fangjun Jiang el 7 de Jun. de 2024 a las 18:09
Hi, I have the same problem, did you find a solution?

Iniciar sesión para comentar.

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 20 de Abr. de 2024
A few things.
  1. Try SimOut=sim(). It used to be, that if there is no return variable specified, then the simulation won't log the output after the simulation is completed. Many questions have been asked before when user could not find the expected output in the base workspace after the simulation is completed. The latest document on sim() doesn't seem to show this tip or limitation anymore but try it anyway.
  2. It sounds like your listener is MATLAB code executed by the StartFcn callback. Depending on the methods used, I am not sure if it is able to monitor the output while the simulation is running using sim(). I know the simulation output data logging when using sim() is done when the simulation is completed, not while the simulation is running.
  3. You could consider adding this monitoring and action into the model using the Assertation block.
  4. Or start from here to see if you can find a better way.


Más información sobre Event Functions en Help Center y File Exchange.




Community Treasure Hunt

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

Start Hunting!

Translated by