MATLAB Answers

Matphree
0

How can I tell EmbeddedCo​der/Simuli​nkCoder to not evaluate expressions containing Matlab tunable parameters when generating C-code from Simulink?

Asked by Matphree
on 9 Jun 2017
Latest activity Commented on by Matphree
on 10 Oct 2017
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:
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 Comments

Sign in to comment.

1 Answer

Answer by Saurabh Gupta on 2 Aug 2017

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.

  1 Comment

Yeah, that what I did, but I prefer to have one +/-limit, is that possible?

Sign in to comment.