This model shows the code generated for a reusable subsystem consisting of a few basic Simulink blocks.
This model contains a subsystem with two copies of an identical subsystem.
You can generate PLC Structured Text code for this subsystem by right-clicking on the subsystem block and select PLC Code -> Generate Code for Subsystem
Alternatively, you can use the following command generatedFiles = plcgeneratecode('plcdemo_reusable_subsystem/ReusableSubsystem');
After the code generation, the Diagnostic Viewer window is displayed with hyperlinks to the generated code files. You can open the generated files by clicking on the links.