Main Content


Class: Simulink.VariantManager
Package: Simulink

Generate reduced model for specified variant configurations


Simulink.VariantManager.reduceModel(Model, Name, Value)


Simulink.VariantManager.reduceModel(Model) creates a reduced model for the specified configuration. The referenced models and library blocks are also reduced. By default, the name of the reduced model and any reduced child referenced model name is the original model name suffixed with _r.

Simulink.VariantManager.reduceModel(Model, Name, Value) specifies the reduction parameters in the Name and Value arguments form.

Input Arguments

expand all

Required field. Model to be reduced, specified as a character vector.

Name-Value Arguments

Specify optional Name,Value arguments. Name is the argument name and Value is the corresponding value. You can specify several name and value arguments in any order as Name1,Value1,...,NameN,ValueN.

Specifies the names of variant configurations. By default, current values of variant control variables are used for reduction.

Specifies the variant control variable values to be used for reduction. By default, the current values of variant control variables are used.

The specified values must be a cell array with variant control variable names and their corresponding values.


'VariableGroups' and 'NamedConfigurations' are mutually exclusive.

Consider this example:

Simulink.VariantManager.reduceModel('iv_model', ...

Specifies the full-range variant control variable values to be used for reduction. This allows you to reduce a model for all valid values of the specified variant control variable. Provide a reference value for variant control variable that results in a successful model compilation.

Consider this example:


You can specify a variant control variable, 'W', as a full-range variant control variable. This allows you to reduce the model for all valid values of variable 'W'. In the example, full-range variant control variable W uses a reference value of 1.

Specifies whether the model should be compiled for simulation or code generation mode as part of reduction. If the model contains variant blocks with the Variant control mode parameter set to sim codegen switching, you can specify the value as codegen to retain the code generation branches of the blocks in the reduced model. For the default value sim, Variant Reducer compiles and retains the simulation branches in the top-level model.

Specifies the folder to place the reduced models and related artifacts. By default, the reduced models are generated in ./reducedModel subfolder in the original model folder.

When the value is true, the Variant Reducer preserves the compiled signal attributes between the original and reduced models by adding signal specification blocks at appropriate block ports in the reduced model. Compiled signal attributes include signal data types, signal dimensions, compiled sample times, etc.

When the value is true, the Variant Reducer displays details of the steps performed during model reduction.

Specifies the suffix to append to the reduced models and the related artifacts.

When the value is true, the Variant Reducer generates a html file with details about the reduced model and any modifications that may be required for masks and callbacks.


To generate summary, you must have Simulink Report Generator license.


% Reduce model based on its variant control variable values in the base workspace.

% Reduce the model associated with a variant configuration data object and configurations to be retained in the reduced model.
Simulink.VariantManager.reduceModel('slexVariantManagement', ...
                                          'NamedConfigurations', {'LinInterStd',

% Reduce the model by specifying variant control variable values. Here, two groups are specified corresponding to 
% {V==1, W==1}, and {V==2, W==2} respectively.
Simulink.VariantManager.reduceModel('iv_model', ...

% Reduce the model by specifying variant control variable values where 'W' is a full-range variant control variable and 'V' is 1. Here, Variant Reducer 
% automatically maps the specification to correspond to the following four explicit groups: {V==1, W==1}, {V==1, W==2}, {V==1, W==3} and {V==1, W==0} respectively.

% Reduce the model by specifying the compilation mode as code generation.
('slexVariantReducer','NamedConfigurations', {'config1'},'CompileMode','codegen','OutputFolder','L:\Models');

Version History

Introduced in R2016a