%% PLC_PreventExternalVarInitialization for Distributed Code Generation
% Generate structured text code for different
% components of your model.

% Copyright 2019 The MathWorks, Inc.


%% Open model
% Open the model by using the following command:
open_system('External_Var_Distributed_Codegen');
%% Configure Model Components for Distributed Code Generation
% 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 <docid:plccoder_ug.mw_85755dbd-0c73-416e-be08-d1b6dfea5c0c
% Remove Initialization Statements for Externally Defined State Variables>.
%% Mark Externally Defined Variables
% # Open the Simulink PLC Coder app.
% For more information, see <docid:plccoder_ref.mw_18cc822d-26bc-48aa-8ab8-3c0bbadb066b
% Simulink PLC Coder app>.
% # Select the |Subsystem| block.
% # Click *Settings*. Navigate to *PLC Code Generation* > *Identifiers*.
% In the |Identifier Names| box enter |child1,child2,DSExportedGlobal|.
% # Click *OK*.
%% Code Generation
% # Open the Simulink PLC Coder app.
% For more information, see <docid:plccoder_ref.mw_18cc822d-26bc-48aa-8ab8-3c0bbadb066b
% Simulink PLC Coder app>.
% # 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*.
%% Generate Code for the Subsystem
% To generate code for the individual subsystem use the plcgenerate
% code function:
%
% plcgeneratecode('External_Var_Distributed_Codegen/Subsystem');
%% Related Topics
%
% <docid:plccoder_ug.mw_7085b311-aa28-49d2-809d-e4a237b306b0
% Generated Code Structure for PLC_PreventExternalVarInitialization>.
