Reduce Models Containing Referenced Subsystems
This example shows how to reduce a Simulink® model that contains Subsystem Reference blocks.
Subsystem reference allows you to save the contents of a subsystem in a separate file and reference it using a Subsystem Reference block. You can create multiple instances referencing the same subsystem file. For more information, see Subsystem Reference.
Using Variant Reducer, you can generate a reduced model that retains only the selected variant configurations that you choose from the parent variant model. For more information on Variant Reducer, see Reduce Variant Models Using Variant Reducer.
Explore Example Model
Open the model
This car windshield wiper model uses subsystem reference to implement the front and rear wipers of a car. The
Wiper subsystem contains two Subsystem Reference blocks named
Front Wiper and
Rear Wiper. Both of these blocks refer to the same subsystem block diagram
The referenced subsystem contains the logic to control the speed of the car's windshield wiper by using different rain sensors. The
Rain Sensor Variant Source block in this model switches between a manual wiper and different variants of automatic rain sensors based on the variant control variable
R. When the value of
R is not equal to
Manual Wiper Setting block becomes active and is used as the input to the
Rain Sensor Model 1 block is the active input. When
Rain Sensor Model 2 is active. To view the definition of
R, see the
PostLoadFcn callback of the model. For simulation workflows, the default value of
R is set to
0, which activates the manual wiper setting.
Open Variant Reducer
1. Open Variant Manager. On the Modeling tab, open the Design section and click Variant Manager.
2. To open Variant Reducer, in the Variant Manager toolstrip, in the Apps section, click Variant Reducer.
Reduce the Model
1. You can modify the reduction settings in the Mode and Options section of the Variant Reducer toolstrip as needed. If you do not modify the settings, Variant Reducer uses default values for reduction.
2. Reduction Mode is set to
Specify variant control values because the model does not have any predefined variant configurations. Since the value of
R is set to
0 in the
PostLoadFcn callback function, that value is picked up for reduction. You can change the value of
R to change the configuration that must be retained in the reduced model.
3. Click Reduce Model. Variant Reducer reduces the top-level model and the referenced subsystem for the variant configuration corresponding to
R=0. The manual wiper setting is retained in the reduced models. The reduced models are named
slexVariantWiperSubsysRef_r.slx by default. This image shows the reduced referenced subsystem model.
For more information on Variant Reducer, see Reduce Variant Models Using Variant Reducer.