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

2 Ansichten (letzte 30 Tage)
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

Antworten (1)

Manoj Mirge
Manoj Mirge am 21 Feb. 2023
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.

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by