matlabsimulinkstateflow

My simple simulink model runs too fast


I have designed a simple simulink and stateflow diagrams on Matlab. It works perfectly! But I have two issues:

1) The model runs too fast. The transition time between two states are amazingly fast that I can not see. I tried to change some parameters, but I was not succeed. What should I change (maybe on Model Configuration Parameters?) to make it slower so we can see the transitions?

2) Currently I just have a constant input. How can I set a series of constants, probably periodic? I assume there should be a special component. I need, like an input of say 0 at time 0, then 1 after 1 minute, 2 at time 3, etc ?

enter image description here

enter image description here


Solution

  • 1) I had the same issues with some interactive simulations where the CPU would make them run too fast for the user to interact. Using a Simulink Real Time Execution Block brought the solution, despite it gives heavy CPU load due to the solution it uses. With this, if you define a 10sec simulation, that's what it will last. If you don't want to pass through this burden, just lengthen your simulation, or inspect thoroughly the scopes throughout the whole simulation (disabling point limit in the Scope, clicking the Parameters button and then unchecking Data History/Limit data points to last...)

    2) Simulink/Sources/Repeating Sequence. You define vectors of times and the value to output in that time. Keep in mind that the block interpolates the values between two points, therefore, if you want to change from 2 to 3 in T=1s, you have to define two points, one U=2 in T=1s and another U=3 in T=1s. For example, 0 in (0..1), 5 in (1..2), 10 in (2..3) and 15 in (3..4):

    Time values:   [0 1 1 2 2  3  3  4]
    Output values: [0 0 5 5 10 10 15 15]