How to force Embedded Coder to unroll the generated for loop of "For Each Subsystem" in generated code?

조회 수: 5 (최근 30일)
I am using for each subsystem to simulate and generate the embedded code for embedded hardware.
I have attached the simple example of For Each Subsystem and generated code.
I tried different Code generation Optimazation settings to unroll the loop in generated code but I am unable to solve it.
I tried also different values for loop unrolling threshold but this does not help or may be I am doing something wrong.
Does anyone know how to solve this issue?
Thank you.

답변 (1개)

Harsh
Harsh 2025년 4월 22일
Hi @SG,
The code generator unrolls loops when the number of iterations is below the threshold set in "Loop unrolling threshold" in advanced parameters. In the attached "For_Each_Subsystem_Example", there are iterations present in the for loop. Therefore you can set the value for "Loop unrolling threshold" as 4. There are two ways to do this:
  • Go to "Code Generation" > "Optimization" > "Advanced Parameters" and set the "Loop unrolling threshold" as 4.
  • Use the "set_param" function in command line.
set_param('For_Each_Example', 'RollThreshold', 4)
Here's how the generated code looks like after optimization -

카테고리

Help CenterFile Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by