how to prioritize the out port execution order?

조회 수: 3 (최근 30일)
ED
ED 2025년 3월 21일
답변: Anushka 2025년 3월 24일
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
Anushka 2025년 3월 24일
Hi @ED,
To ensure that the Outport execution occurs after all filter calculation, you should:
  1. Wrap each filter block and output block in ‘nonreusable atomic subsystems’.
  2. Enable ‘Late Inline’ to prevent Simulink Coder optimizations from changing the execution order.
The following steps resolved the issue for me:
  1. 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
  • InlineApply ‘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 ParametersSimulation 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!

카테고리

Help CenterFile Exchange에서 Interactive Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by