When Simulink converts code, how is the simulation step size (reference sampling frequency) of the system handled, and what variables in the code are reflected in the amount r

1 次查看(过去 30 天)
When Simulink converts code, how is the simulation step size (reference sampling frequency) of the system handled, and what variables in the code are reflected in the amount related to the simulation step, and whether it can be individually found and modified

回答(1 个)

Manoj Mirge
Manoj Mirge 2023-2-21
Hi,
I am assuming that you want to inspect the code generated by Simulink Coder.
In that case if you have model named My_Model.slx and you have generated code using Simulink Coder. Then you can see the step time initialized in your code in the My_Model.c file.
The step time initialization statement will be in My_Model_initialize(void) function in My_Model.c file.
The step time will be stored in variable named My_Model_M->Timing.stepSize0. As it is initialized inline you can change the step time in your code manually. I am attaching image of the same below.
In the above example, I have generated code for Simulink model named My_Model.slx and I have set step size as 0.147 in My_Model.slx file by following below steps:
  • In Simulink, go to MODELING tab.
  • Open Configuration parameters dialogue box.
  • Go to solver Tab
  • Change Fixed-step Size field and specify your step size.
As you can see step size specified by me in Simulink model can be seen in the generated code.
Hope this will help you.

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by