Parameter Interfaces for Reusable Components

You can use subsystems, referenced models, and custom library blocks as reusable components in other models. For guidelines to help you decide how to componentize a system, see Capabilities of Model Components.

Typically, a reusable algorithm requires that numeric block parameters, such as the Gain parameter of a Gain block, either:

  • Use the same value in all instances of the component.

  • Use a different value in each instance of the component. Each value is instance specific.

By default, if you use a literal number or expression to set the value of a block parameter, the parameter uses the same value in all instances of the component. If you set multiple block parameter values by using a MATLAB® variable, Simulink.Parameter object, or other parameter object in a workspace or data dictionary, these parameters also use the same value in all instances of the component.

Referenced Models

If you use model referencing to create a reusable component, to set parameter values that are specific to each instance, configure model arguments for the referenced model. When you instantiate the model by adding a Model block to a different model, you set the values of the arguments in the Model block. When you add another Model block to the same parent model or to a different model, you can set different values for the same arguments. Optionally, if you create more than two instances, you can set the same value for some of the instances and different values for the other instances.

If a model has many model arguments, consider packaging the arguments into a single structure. Instead of configuring many arguments, configure the structure as a single argument. Without changing the mathematical functionality of the component, this technique helps you to reduce the number of model argument values that you must set in each instance of the component.

For more information about model arguments, see Parameterize Instances of a Reusable Referenced Model.

Subsystems

If you use subsystems or custom libraries to create reusable components, to set parameter values that are specific to each instance, use masks, mask parameters, and parameter promotion. When you instantiate the component in a model, you set the values of the mask parameters in the Subsystem block. When you instantiate the component again in the same model or a different model, you can set different values for the same mask parameters. Optionally, if you create more than two instances, you can set the same value for some of the instances and different values for the other instances.

If the subsystem has many mask parameters, consider packaging the parameters into a single structure. Instead of configuring many mask parameters, configure the structure as a single parameter. Without changing the mathematical functionality of the component, this technique helps you to reduce the number of mask parameter values that you must set in each instance of the component.

For more information about subsystems, see Subsystem. For more information about custom block libraries, see Design and Create a Custom Block. For more information about masks, see Masking Fundamentals. For more information about structures, see Organize Related Block Parameter Definitions in Structures.

Related Topics