MATLAB: Is there an inefficient loop generated in the initialization function of generated code in Real-Time Workshop 6.0 (R14)

dworkfunctioninitializationrollrtwsimulink coderthreshold

In generated code, a block's DWork vectors are usually set to zero in the initialization function. The set to zero operations are always done using a for loop even if the widths of the DWork vectors are less than the specified roll threshold.

Best Answer

This has been fixed in Real-Time Workshop 6.1 (R14SP1). In Real-Time Workshop 6.1 (R14SP1), the loop is only used when the width of the DWork vector is not less than roll threshold. If you are using a previous version, read the following:
This has been verified as a bug in Real-Time Workshop 6.0 (R14) in the way that it handles generating initialization function code.
There are currently no known workarounds.