You can reuse a subsystem in a model by creating a subsystem reference, which saves the subsystem to an SLX file. To reuse that subsystem, you can use subsystem reference blocks, which reference that same SLX file.
Consider the slexSSRef_model model.
This model contains two subsystems referencing the same subsystem file, sref_timesK.
The sref_timesK subsystem contains Inport, Gain, and
Outport block and is masked using Model Mask. An Edit
parameter is added to the mask to pass value using the variable
This model is configured to demonstrate these capabilities of subsystem reference:
Instance specific parameterization: You can specify different
parameter values for each instance of a referenced subsystem. For example, here the
input value (
k) for the Edit parameter from
Instance specific debugging: In this example, you have two instances of subsystem, referencing the saved subsystem file, sref_timesK. Each instance is driven by its own set of inputs in the top model. When you need to debug a referenced subsystem, you can dive into each instance and look for errors and debug them.
Dimension adaptability: While referencing subsystems, the top
model can drive multiple dimensions. The
Subsystem instance driven by
a signal of dimension 1 and the
Subsystem1 instance is driven by a
signal of dimension 4. In both instances you can see that the referenced subsystems
adapt to have 1 dimension and 4 dimensions respectively in the output.
Multiple sample time handling: In this model, the two instances
of referenced subsystems are configured to run with two different sample times
0.02. This overcomes the limitations of
model referencing where multiple sample times are not supported.