Main Content

Improve Parameter-Sweeping Efficiency Using Simscape Run-Time Parameters

Simscape™ run-time parameters are run-time configurable. They allow you to forgo recompiling if you change parameter values between iterative simulations during parameter surveys. You can only test a single value for a compile-time configurable parameter without recompiling your model.

You can benefit from this advantage when you perform parameter sweeps using fast restart, model referencing, or code generation. Code generation allows you to update Simscape run-time parameters between simulation runs using:

  • Rapid simulation (RSim) on development or target hardware

  • Real-time simulation on target hardware

Model Referencing with Run-Time Configurable Parameters

You can use Simulink® Model blocks to represent one model within another. Each instance of a Model block represents a reference to another model, called a referenced model. For simulation and code generation, the referenced model effectively replaces the Model block that references it. To change the behavior of a referenced model without recompiling, specify a Simscape run-time parameter value in the referenced model using either global parameters or model arguments.

For information on using and parameterizing referenced models, see Model Reference Basics and Configure Instance-Specific Values for Block Parameters in a Referenced Model.

Code Generation with Run-Time Configurable Parameters

Simscape run-time parameters allow you to test your design over a range of values for plant parameters without recompiling or redeploying code. You can:

  • Change the value of a Simscape run-time parameter in both your plant model and in your generated code on your development computer for a rapid or real-time simulation.

  • Update a run-time configurable parameter in your deployed code before you run your simulation as an executable on an external target machine.

For an example that uses Simscape run-time parameters for real-time simulation see Change Parameter Values on Target Hardware.

Note

Rapid simulation (RSim) uses portions of the Simulink Coder™ product to create an executable. These modes replace the interpreted code normally used in Simulink simulations, which shortens model run time. Although RSim uses Simulink Coder code generation technology, you do not need Simulink Coder software on your development computer to accelerate your model with RSim. For more information, see Accelerate, Refine, and Test Hybrid Dynamic System on Host Computer by Using RSim System Target File (Simulink Coder).

Fast Restart with Simscape Run-Time Parameters

Changing parameter values does not require you to recompile the model between simulation runs unless the changes alter the model structurally. However, when you use normal mode simulation without fast restart, each simulation compiles the model. The compiling occurs even if the new values do not change the structure of the model and each recompile increases the overall simulation time.

With Simulink fast restart, you can modify Simscape run-time parameters from the workspace variable, without recompiling. For an example that shows how to specify a Simscape run-time parameter and change the parameter value using fast restart, see Specify and Change a Simscape Run-Time Parameter.

Related Topics