How can I tell EmbeddedCoder/SimulinkCoder to not evaluate expressions containing Matlab tunable parameters when generating C-code from Simulink?
3 次查看(过去 30 天)
显示 更早的评论
Hi, I have a saturation block in Simulink where I set upper and lower limits based on a tunable parameter and have the output port generated as global variable:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165017/image.png)
In the generated C-code the lower limit expression is evaluated to:
srt_gyroXsaturated = rtU.gyro_X >= srt_gyroLimitX ? srt_gyroLimitX :
rtU.gyro_X <= -0.349040151F ? -0.349040151F : rtU.gyro_X;
What I want is that '-srt_gyroLimitX' is not evaluated to '-0.349....' but left "as is" in the generated code. How can I achive that?
0 个评论
回答(2 个)
Saurabh Gupta
2017-8-2
For tunability in code generation, the parameter needs to be a variable. Parameters specified as expressions are evaluated and inlined. You could specify the limits as 2 separate variables to ensure that code generation preserves the tunability.
Ben Rancici
2019-9-30
Same question as Matphree: how to prevent block parameter evaluation in the generated code?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!