Function Reuse in Generated Code

This model shows how to configure a subsystem for code reuse. To specify that a subsystem's code executes as an atomic unit, select the Treat asatomic unit parameter on the block parameters dialog box. This parameter enables the Function Packaging parameter of the Code Generation tab. The Function Packaging Parameter has these four settings:

Example Model

The rtwdemo_ssreuse model contains two identical subsystems, SS1 and SS2. For these subsystems, the Function packaging parameter is set to Reusablefunction, and the Function name parameter is myfun. The subsystems are parameterized masked subsystems. To see the contents of the masked subsystems, right-click the subsystem blocks and select Mask > Look UnderMask.