This example shows how to autogenerate structured text code for subsystem reference blocks.
To open the Simulink test bench model, use the following command.
open_system('mSubSysRefSystemIntegration')
To generate code for the subsystem use plcgeneratecode
generatedfiles = plcgeneratecode('mSubSysRefSystemIntegration/TopSystem');
### Generating PLC code for 'mSubSysRefSystemIntegration/TopSystem'. ### Using <a href="matlab:configset.showParameterGroup('mSubSysRefSystemIntegration', { 'PLC Code Generation' } )">model settings</a> from 'mSubSysRefSystemIntegration' for PLC code generation parameters. ### Begin code generation for IDE <a href="matlab:configset.showParameterGroup('mSubSysRefSystemIntegration', { 'PLC Code Generation' } )">codesys23</a>. ### Emit PLC code to file. ### Creating PLC code generation report <a href="matlab:web('/tmp/BR2020bd_1444674_32127/publish_examples1/tp6566b536/ex94427949/plcsrc/html/mSubSysRefSystemIntegration/mSubSysRefSystemIntegration_codegen_rpt.html')">mSubSysRefSystemIntegration_codegen_rpt.html</a>. ### PLC code generation successful for 'mSubSysRefSystemIntegration/TopSystem'. ### Generated files: <a href="matlab: edit('plcsrc/mSubSysRefSystemIntegration.exp')">plcsrc/mSubSysRefSystemIntegration.exp</a>