%% Using Multiword Fixed-Point Data
% This example shows a simple use of multiword fixed-point data in
% Stateflow(R) charts. You can define multiword fixed-point data at the
% chart level, with one of the following scopes:
% 
% * Input
% * Output
% * Parameter
% * Data Store Memory
%
% You can also pass these data as inputs and outputs to and from MATLAB(R)
% functions, MATLAB truth tables, and Simulink(R) functions in Stateflow
% charts.

% Copyright 2009-2018 The MathWorks, Inc.

clear
close all 
bdclose all

model = 'sf_multiword_fixpt';
open_system(model);
rt = sfroot;
m = rt.find('-isa', 'Stateflow.Machine', 'Name', model);
c = m.find('-isa', 'Stateflow.Chart');
c.Visible = 0;
evalc(['sim(''' model ''')']);

%%
% Chart MultiwordFixptIO takes in an input, |data|, that is a multiword
% fixed-point type, and returns an output, |out|, that is also a multiword
% fixed-point data type. 

open_system(model);
c.Visible = 1;

%%
% The chart defines a Simulink function |foo| that declares both its input
% and output to be of multiword fixed-point type. |foo| returns the value
% of its input, incremented by a fixed-point constant value. At each time
% step, the chart MultiwordFixptIO passes its input to |foo|, and assigns the
% output from |foo| to |out|.

open_system([model '/' c.Name '/foo']);

%%
bdclose all;
close all;
clear
