Why is my Embedded MATLAB Block evaluated multiple times per time step in Simulink 7.6 (R2010b)?

4 views (last 30 days)
I am running a Simulink model with a fixed-step continuous solver and I see that my Embedded MATLAB Block is executed multiple times per time step. For example if I use the ODE3 solver, the block is executed 3 times per time step. How do I set the block to execute only once per time step?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 8 Apr 2011
Except for ODE1, the fixed-step continuous solvers use multiple minor time steps to solve the differential equations for the major time steps. If you want an Embedded MATLAB Block to only run at the major time steps you can set the Sample Time accordingly in the Ports and Data Manager:
- Open the Embedded MATLAB Editor for the block you want to run on the major time steps
- Choose Tools -> Edit Data/Ports
- Set the update method to "Discrete" and specify the Sample Time as the Sample Time of the Simulink model.
You may want to create a variable in the Workspace to set both the Sample Time of the block and the model at the same time.

More Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Products


Release

R2010b

Community Treasure Hunt

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

Start Hunting!