how to prioritize the out port execution order?
Show older comments
This is the example of the model, I want to update the output after the Filter 1 and filter 2. But the code generated is against the will even the execution orders were changed.


So, how to set the configuration to achieve updating all calculation before updating outport?
Answers (1)
Anushka
on 24 Mar 2025
To ensure that the Outport execution occurs after all filter calculation, you should:
- Wrap each filter block and output block in ‘nonreusable atomic subsystems’.
- Enable ‘Late Inline’ to prevent Simulink Coder optimizations from changing the execution order.
The following steps resolved the issue for me:
- Group the Filter and Outport Blocks:
- Select Filter 1 and Filter 2, then right-click → Create Subsystem.
- Do the same for the Outport block.
- You should now have ‘Filter_Subsystem’ and ‘Outport_Subsystem’.
2. Set the Subsystems as Nonreusable:
- Double-click each subsystem → Block Parameters.
- In the Code Generation tab: Function packaging → Nonreusable function
- Inline → Apply ‘Late Inline’ via MATLAB scripting in the command line:
set_param(‘model_name/subsystem_name’, 'RTWSystemCode', 'Inline');
3. Adjust the Execution Order:
- Go to Model Configuration Parameters → Simulation Order.
- Set the execution order so that: ‘Filter_Subsystem’ executes before ‘Outport_Subsystem’.
- This guarantees all filtering calculations are completed before updating the Outport.
You can refer to the following documentation to get details about how to create a subsystem: https://www.mathworks.com/help/simulink/ug/creating-subsystems.html
Hope this helps!
Categories
Find more on Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!