Main Content

Set Priority and Initial Target for Block Variables

When you open the Variables tab of a block dialog box, it lists all the public variables specified in the underlying component file, along with priority, beginning (target) value, and unit. For example, if you add a Translational Spring block to your model, double-click it to open its dialog box, and then click the Variables tab, it looks like this:

For details on these variables and their usage in the block equations, click the Source code link in the block dialog box to view the underlying Simscape™ source file.


The Source code link is available for all the Foundation library blocks that have a Variables tab. Blocks from the add-on products, like Simscape Electrical™ or Simscape Fluids™, do not have a Source code link in the block dialog box. See the block reference page for information on relevant equations and specific initialization considerations.

To specify the initial deformation of the spring, select the Override check box next to the Deformation variable, to indicate that you are overriding the default values. Select the initialization priority for the variable, by setting its Priority drop-down to High, Low, or None. Type a new number into the Beginning Value field and change the unit, if desired. The Unit drop-down lists contains all the units defined in the unit registry that are commensurate with the one specified in the variable declaration. In the following dialog box, Deformation is specified as a high-priority variable with the initial target of 20 mm.

If you clear the Override check box next to a variable name, its Priority, Beginning Value, and Unit fields switch back to defaults specified in the component file. However, if you select the check box again, these fields will retain their last specified value for when they were overridden.


The variables included in the Variables settings are run-time configurable by default. You can tune a block-level variable-initialization target value between simulation runs if you specify the target value using a variable that you save to the MATLAB® workspace.

For more information, see Run-Time Configurability for Block-Level Variable Initialization Target Values.

Related Topics