%% Generating Structured Text for Simulink(R) Model with Fixed-Point Data Types
% 
%   Copyright 2007-2013 The MathWorks, Inc.
%
% This model shows generating code for fixed-point signals.
%

mdl = 'plcdemo_fixed_point';
evalc('open_system(mdl)');
evalc('sim(mdl)');

%%
% Open the subsystem at the top level named 'Subsystem'. Simulate the model
% and observe the fixed point types displayed on the signals.
open_system('plcdemo_fixed_point/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_fixed_point/Subsystem');

%%
% 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.
% You will notice that all the fixed-point input/outputs in the model as
% well as internal state variables have been lowered to integer data types.

