MATLAB: Does the generated S-function have incorrect sample times when generated from a subsystem using the Real-Time Workshop

buscodegenerationinportinputmulti ratemultiraterealrtws-functionselectorsimulink codertimeworkshop

Why does my generated S-function have incorrect sample times when generated from a subsystem using the Real-Time Workshop?
I have a subsystem which has signals with multiple sample rates for its input. I generate an S-function from the subsystem. I then replace the subsystem with my generate S-function. When I simulate, I receive the following warning:
Warning: Inconsistent sample times. Sample time of signal ([0, 0]) driving input port 5 of block
'untitled1/BusSystem1/BusSystem1_sfcn' differs from the expected sample time at this input port
([1, 0]).

Best Answer

This has been verified as a bug in the Real-Time Workshop in the way that subsystems with multiple sample rate inputs are generated to S-functions.
Currently, to work around this issue, try using a Bus Selector block which outputs signals with the same sample rate as the input to the subsystem to be compiled. Compile only the single rate subsystem.