%SIMULINK.VARIANTVARIABLE Variable with different definitions based on
%variant conditions
%
%   Simulink.VariantVariable class can be used to create object variables
%   that take different values and/or types based on variant conditions.
%   This variable can be used as the value for a block parameter, (e.g. a
%   Gain block's Value parameter) to define variant parameters.
%
%   P = Simulink.VariantVariable creates a variable P with no choices.
%
%   P = Simulink.VariantVariable('Choices', {'Condition_1', Value_1,...
%   'Condition_2', Value_2, ...}) creates a variant variable with choices
%   specified in the Condition-Value pairs cell-array. Condition_i is a
%   variant condition expression that should evaluate to true/false, and
%   Value_i is the corresponding value of P that will be used if the
%   condition is true.
%   For example,
%   P = Simulink.VariantVariable('Choices', {'V==1', 1.5, 'V==2', 8.3})
%   creates a variant variable P with 2 choices. V should be a
%   Simulink.VariantControl object. When V=1, P is 1.5 and when V=2, P is
%   8.3.
%
%   P = Simulink.VariantVariable('Choices', {'Condition1', Value1,...
%   '(default)', ValueD}) uses the default value ValueD for P when none of
%   the other specified conditions are true.
%
%   P = Simulink.VariantVariable('Specification', 'sp', 'Choices', {...})
%   uses Simulink.Parameter object "sp" to define specifications, such as
%   data type, for all the variant choices. Individual choices can override
%   this specification explicitly when setting the choice value.
%   For example,
%   sp = Simulink.Parameter(int8([]));
%   sp.CoderInfo.StorageClass = 'Custom';
%   sp.CoderInfo.CustomStorageClass = 'Define';
%   sp.CoderInfo.CustomAttributes.HeaderFile = 'variant_parameters.h';
%   P = Simulink.VariantVariable('Specification', 'sp',...
%       'Choices', {'V==1', 2, 'V==2', 3});
%   defines all the choices to be int8 data type with the specified custom
%   storage class attributes.
%
%   P = Simulink.VariantVariable('Bank', 'ParamBank', 'Choices', {...})
%   uses Simulink.VariantBank object "ParamBank" to define parameter bank,
%   so that the variant parameters will be placed together in a parameter
%   bank structure in the generated code.
%   For example,
%   ParamBank = Simulink.VariantBank('Name', 'ParamBankA');
%   ParamBank.VariantConditions = {'V == 1', 'V == 2'};
%   P = Simulink.VariantVariable('Bank', 'ParamBank',...
%       'Choices', {'V == 1', 2, 'V == 2', 3});
%   defines all the choices to be placed in a parameter structure named 
%   'ParamBankA' in the generated code.
%
%   Using Simulink.VariantControl objects in variant condition expressions
%   enables specifying the "activation time" for variant controls, which
%   can help in enforcing constraints on the parameter. For more
%   information, type "help Simulink.VariantControl".
%
%   You can use arithmetic and logical operations directly on the object,
%   which corresponds to applying them on the active choice value. For
%   example, "P+2" will add 2 to the active variant choice value of P.
%
%   Simulink.VariantVariable methods:
%
%   addChoice - Add new variant choice with specified condition and value
%   removeChoice - Remove variant choice specified by variant condition
%   setChoice - Set new or redefine existing variant choice
%   getChoice - Return specified choice by condition or all choices
%
%   Example 1: Create a variant variable with 2 choices and use arithmetic
%   operator(s) on the variable.
%       V = Simulink.VariantControl('Value', 1); % Variant control variable
%       P1 = Simulink.VariantVariable('Choices', {'V==1', 3.5, 'V==2', 8.3});
%       P1*3 % returns 3.5*3 = 10.5
%
%   Example 2: Specify common custom attributes for all variant parameter
%   choices.
%       % Use Simulink.Parameter to define the attributes for all variant
%       % variable choices.
%       sp = Simulink.Parameter(int8([])); % nominal value, ignored
%       sp.CoderInfo.StorageClass = 'Custom';
%       sp.CoderInfo.CustomStorageClass = 'Define';
%       sp.CoderInfo.CustomAttributes.HeaderFile = 'vparam.h';
%       % Use Simulink.VariantControl as variant control.
%       % Default activation time is 'update diagram'.
%       W = Simulink.VariantControl('Value', 2);
%       % Create a variant variable with 2 choices and specified attributes.
%       P2 = Simulink.VariantVariable('Specification', 'sp',...
%          'Choices', {'W==1', 4, 'W==2', 8});
%
%   Example 3: Create variant variable with 2 choices and use
%   Simulink.VariantControl to enforce consistent attributes for all
%   choices. 
%       % Below activation time enforces consistent attributes for all
%       % choices.
%       X = Simulink.VariantControl('Value', 1, ...
%           'ActivationTime', 'update diagram analyze all choices');
%       P3 = Simulink.VariantVariable('Choices',...
%           {'X==1', int8(3), 'X==2', int8(7)});
%       % Using P3 with below choice in a model will error when the model
%       % is compiled as the data type of the choice is not int8. 
%       P3 = setChoice(P3, {'X==3', 5.1});
%
%   Example 4: Create a variant variable with Simulink.Parameter variables
%   as choice values.
%       % Specify Simulink.Parameter variable names as choice values for
%       % the variant parameters in generated code to import values from 
%       % external parameters.
%       kv_hatchback = Simulink.Parameter(3);
%       kv_hatchback.CoderInfo.StorageClass = 'ImportedExtern';
%       kv_sedan = Simulink.Parameter(6); 
%       kv_sedan.CoderInfo.StorageClass ='ImportedExtern'; 
%       kv = Simulink.VariantVariable('Choices', ...
%            {'V == 1', 'kv_hatchback', 'V == 2', 'kv_sedan'});
%
%   Example 5: Create a variant variable with choice values having
%   different dimensions for code compile activation time.
%       % Specify choice values with different size values for code 
%       % compile activation time.
%       V = Simulink.VariantControl('Value', 1, ...
%           'ActivationTime', 'code compile');
%       kv = Simulink.VariantVariable('Choices',...
%            {'V == 1', [1,2,3], 'V == 2', [1,2,3,4,5]});
%
%   Example 6: Create variant variables that are placed in same parameter
%   bank structure.
%       % Specify variant parameter bank
%       ParamBank = Simulink.VariantBank('Name', 'ParamBankA');
%       ParamBank.VariantConditions = {'V == 1', 'V == 2'};
%       ParamBank.CoderInfo = 'ParamBankCInfo';
%       ParamBankCInfo = Simulink.VariantBankCoderInfo;
%       ParamBankCInfo.HeaderFile = 'variant_params.h';
%       ParamBankCInfo.DefinitionFile = 'variant_params.c';
%       % Define variant control
%       V = Simulink.VariantControl('Value', 1, ...
%           'ActivationTime', 'startup');
%       % Define variant parameters
%       kv = Simulink.VariantVariable('Choices',...
%            {'V == 1', [1,2,3], 'V == 2', [6,8,9]}, 'Bank', 'ParamBank');
%       kv1 = Simulink.VariantVariable('Choices',...
%            {'V == 1', [20,4], 'V == 2', [9,10]}, 'Bank', 'ParamBank');
%       
%   See also Simulink.VariantControl, Simulink.Parameter,
%   Simulink.VariantBank, Simulink.VariantBankCoderInfo.

%   Copyright 2020-2022 The MathWorks, Inc.

% LocalWords:  sp vparam kv CInfo
