%% Simulink.Parameter Objects for Code Generation of Variant Parameters
% If you intend to generate code for a model containing variant parameter values, specify variant control variables as MATLAB® variables or Simulink.Parameter objects. Simulink.Parameter objects allow you to specify other attributes (such as data type) that are required for generating code.
% Note:
% You can define a variant control variable of type Simulink.Parameter only in the base workspace or in a data dictionary. Defining Simulink.Parameter type of variant control variables in the mask or model workspace is not supported. For more information on storage locations for variant control variables, see Storage Locations for Variant Control Variables in Variant Condition Expressions.
% Simulink.Parameter objects within structures and that have data types other than Simulink.Bus objects are not supported.
% In the MATLAB Editor, define a Simulink.Parameter object.

VSSMODE = Simulink.Parameter;
VSSMODE.Value = 1;
VSSMODE.DataType = 'int32';
VSSMODE.CoderInfo.StorageClass = 'Custom';
VSSMODE.CoderInfo.CustomStorageClass = 'ImportedDefine';
VSSMODE.CoderInfo.CustomAttributes.HeaderFile ='rtwdemo_importedmacros.h';

% Variant control variables defined as Simulink.Parameter objects can have one of these storage classes:
% Define or ImportedDefine with header file specified
% CompilerFlag
% SystemConstant (AUTOSAR)
% Your own storage class that defines data as a macro
% You can also convert a scalar variant control variable into a Simulink.Parameter object. For more information, see Convert Variant Control Variables into Simulink.Parameter Objects.
% Specify the object as a variant control using a Simulink.VariantVariable object.

vpObj = Simulink.VariantVariable('Choices', {'VCtrl == 1',1000,'VCtrl == 2',2000});

% Activate one of the variant values by defining a control variable VCtrl and setting its value to VSSMODE in a Simulink.VariantControl object. This condition activates the value 1000 and assigns this value to vpObj.

VCtrl = Simulink.VariantControl('Value',VSSMODE,'ActivationTime','code compile')

% Copyright 2020 The MathWorks, Inc.