Generate structured text code for different components of your model.
Open the model by using the following command:
open_system('External_Var_Distributed_Codegen');
To autogenerate structured text code by preventing initialization statements for externally defined variables for external code integration later on, use remove Initialization Statements for Externally Defined State Variables. for more information, see Remove Initialization Statements for Externally Defined State Variables.
Open the Simulink PLC Coder app. For more information, see Simulink PLC Coder.
Select the Subsystem
block.
Click Settings. Navigate to PLC Code Generation > Identifiers. In the Identifier Names
box enter child1,child2,DSExportedGlobal
.
Click OK.
Open the Simulink PLC Coder app. For more information, see Simulink PLC Coder.
Select the Subsystem
block.
Click Settings. Navigate to PLC Code Generation > Interface. Select the Remove Initialization Statements for externally defined state variables check box.
Click OK.
To generate code for the individual subsystem use the plcgenerate code function:
plcgeneratecode('External_Var_Distributed_Codegen/Subsystem');
Generated Code Structure for PLC_PreventExternalVarInitialization.