Search code examples
timesimulationsimulink

Display time for specific event in simulink/stateflow


I am trying to get the time at which a specific condition in my simulation occurs. Specifically, in my simulink model I am comparing two inputs and I need to save to the workspace the time at which they equal each other. Any help is greatly appreciated!


Solution

  • You can do this with the following 2 steps:

    1. Inside a Triggered Subsystem, put a Clock block feeding directly into a To Workspace block. Make the subsystem rising edge triggered.
    2. Outside the Triggered Subsystem, compare your two signals, and feed the comparison into the trigger port.

    The times at which the comparison is true will get written (as a vector) to the specified workspace variable.