%% Create Variant Controls Using MATLAB(R) Enumeration Class 
% Each variant choice in a Simulink(R) model is associated with a
% conditional expression called a _variant control_. The variant control which
% evaluates to true determines the active variant choice in the model.   
% This example shows how to create variant controls in your model using
% a MATLAB(R) enumeration in the variant condition expressions. In code
% generation, enumerated types improve readability because condition values
% are represented as meaningful names instead of literal values.

% Copyright 2020 The MathWorks, Inc.

%% Explore the Model
% Open the model |slexVariantSetupUsingIntEnums|. It contains two variant
% choices, |Linear controller| and |Nonlinear controller|. Variant Sink and
% Variant Source blocks are used to implement the variant regions.
open_system('slexVariantSetupUsingIntEnums');
%% Specify the Enumeration Class in a MATLAB(R) File
% You can create an enumeration class by adding an enumeration block to a
% class definition and saving it in a MATLAB file. In this
% example, the enumeration |ControllerChoice| (saved in |ControllerChoice.m|)
% derives from the built-in numeric type |int32|. It defines two enumeration
% members, |Linear| and |Nonlinear|. 
%%
% <include>ControllerChoice.m</include>
%% Create a Variant Control Variable
% This example uses the MATLAB variable |V| as the variant control
% variable to store the variant choice that is currently active.
%%
% In the MATLAB Command Window, type:
% 
%  V = ControllerChoice.Linear;
%
%% Build the Variant Condition Expression 
% You can set the variant controls from the Variant Manager. To open the
% Variant Manager, right-click the variant badge on the Variant Sink
% or Variant Source block and select *Open in Variant Manager* . 
%%
% You can see how the enumeration members and the control variable is used
% to create the condition expressions |V == ControllerChoice.Linear| and |V
% == ControllerChoice.Nonlinear|.  All supported Simulink enumerations
% can be used to build the condition expression. For information on
% enumerations in Simulink, see <docid:simulink_ug#bspsfem Simulink
% Enumerations>.
%%
% <<../variantmanager.png>>
%
%% See Also
% * <docid:simulink_ug#bt_5z2b-1 Introduction to Variant Controls>
% * <docid:simulink_ug#mw_b1911ab0-0a22-4665-a6a6-46d68abc7d3d Approaches for Specifying Variant Controls>
% * <docid:simulink_ug#brscdkf-1 Use Enumerated Data in Simulink Models>