MATLAB: How to prevent Real-Time Workshop 7.2 (R2008b) from generating no-op code for the model

codedeadeliminatenoopoptimizesimulink coder

When I generate code for my model using Real-Time Workshop 7.2 (R2008b), no-op code is generated (due to dead-code elimination). I would like to preserve the output signal from my model in the generated code.

Best Answer

In order to prevent Real-Time Workshop from generating no-op code in R2008b, you can uncheck the 'Block Reduction' option in the Optimization pane in the Configuration Parameters dialog window (Click on Simulink -> Configuration Parameters).
However, please note that turning off block reduction for a whole design could be expensive in terms of RAM/ROM and operation speed. To preserve just one signal in the generated code, you can instead declare the signal as a test point. You can do this via the Signal Properties dialog window for the signal (Right-click on the signal then go to Signal Properties) .