MATLAB: How to hold a true signal for a defined time after conditions are met in Simulink 8.3 (R2014a)

simulink

How can I hold a true signal for a defined time after conditions are met in Simulink 8.3 (R2014a)?

Best Answer

  • Enabling a signal for a specified amount of time when triggered can be accomplished in several different ways in Simulink. The basic procedure to implement this type of logic is outlined, as follows:
    1) Use a Simulink Clock block to get the current simulation time
    2) Capture the current time when the enable/trigger event occurs
    3) Disable the signal/enabled subsystem after the desired amount of time passes
    See the attached example for an implementation with a MATLAB Function block using persistent variables.
    More information on persistent variables in MATLAB Function blocks can be found, as follows:https://www.mathworks.com/help/matlab/ref/persistent.html