MATLAB: Does the MATLAB Function Block parameter not get inlined when generating structured text in PLC Coder 1.4 (R2012b)

Simulink PLC Coder

I have a parameter defined in my MATLAB function block, however it appears with a global constant declaration in the generated PLC code. I would like it to be inlined in the PLC code.

Best Answer

The reason that the variable is not being inlined is because it is being declared as a type 'single' using the SINGLE function.
PLC Code generation then needs to declare this variable of the correct precision. If you declare the variable without using the SINGLE function, the value will be inlined in the resulting code.