Simulink Coder: Prevent optimization of a signal

Simulink Coder tends to optimize out signals, and these output signals won’t be saved to MODEL_NAME_B

Just Make the signal a testpoint (right click -> Properties -> Testpoint):

Simulink Testpoint dialog

When it’s a testpoint, even this completely unconnected signal will not be optimized out:

Simulink Testpoint

to MODEL_NAME_A and connect the output signal to the input of the function block. This will prevent the signal from being optimized out.


Check out similar posts by category: Matlab/Simulink