how to prioritize the out port execution order?
이전 댓글 표시
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?
답변 (1개)
Anushka
2025년 3월 24일
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!
카테고리
도움말 센터 및 File Exchange에서 Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!