MATLAB: Does the code generated using the ‘Build subsystem…’ with Real-Time Workshop 5.1 (R13SP1) use the default step size instead of the specified step size

buildcodecorrectdefaultgenerationinsteadsimulink codersize;specifiedstepsubsystemwrong

The code generated using the 'Build subsystem…' with Real-Time Workshop 5.1 (R13SP1) uses the default step size instead of the specified step size.
The default step size is (Tstop – Tstart) / 50.
This problem only occurs if the solver is set to fixed-step, subsystem contains only continuous time blocks with inherited sample times, and the subsystem does not contain a continuous state.

Best Answer

This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
This is a bug in Real-Time Workshop 5.1 (R13SP1) in the way that subsystems are built with fixed-step solvers.
To work around this issue, try adding a 'dummy' discrete state to the model, or specify a discrete step size for all of the blocks. As an example of a dummy state, connect a Ground to a Unit-delay to a Terminator then set the sample time of the Unit Delay block.