Edit Block Parameters
Parameters specify how a block behaves in the model. You can use the default parameter values or set your own values using the block icon, the Block Parameters dialog box, or the Property Inspector. Specify your own values directly or as variables.
You can edit the values of multiple parameters at once using the Model Data Editor or the Model Explorer. Use the Model Data Editor to batch edit the core parameters of blocks, such as the Gain parameter of Gain blocks or the Constant Value parameter of Constant blocks. The Model Data Editor does not show all block parameters. To batch edit parameters the Model Data Editor does not show, use the Model Explorer.
To get and set the values of parameters programmatically, use the get_param
and set_param
functions.
To edit and manage workspace variables, use the Model Explorer. See Edit and Manage Workspace Variables by Using Model Explorer for details.
Edit Parameters on Block Icon
For blocks that display a parameter value on the block icon, you can edit the value directly on the icon:
Select the block.
Click on the parameter value on the block icon.
Enter a new value.
Press Enter.
Note
The block icon only displays the new value if the value fits on the icon.
You can also edit enumerated block parameter values on the block icon:
For the block parameters that have a fixed set of values, you can select the value from a list on the block icon using the cursor or arrow keys.
These blocks have this feature:
For example, for the Rounding Function block, you can select the Function parameter from a list of values:
Select the Rounding Function block.
Point to the block icon. The editable parameter value appears underlined.
Click the underlined text to edit the value. A list with Function parameter values appears.
Select a new value from the list using the cursor or the arrow keys.
The Goto and From blocks are a special case. While they pair with each other as related blocks, for the Goto block, you can only type a new Goto tag parameter value on the block icon. For the From block, you can only select the Goto tag parameter value from a list on the block icon.
Note
Typing a new value for the Goto block removes unmatched values from the list.
For example, consider a From block with the Goto Tag parameter value
sensor_A
and three Goto blocks with the Goto Tag parameter valuessensor_A
,sensor_B
, andsensor_C
.To change the Goto Tag parameter value of the highlighted Goto and From block pair to a new value:
Select a Goto block, and then click the text on the block icon.
Enter a new name for the tag.
Press Enter.
Select the From block.
Click the text on the block icon. A list with Goto tag parameter values appears.
Select the new tag name that you assigned to the Goto block.
Alternatively, to connect the From block to one of the other two Goto blocks, expand the list on the From block icon and select the tag of the Goto block to which you want to connect.
Edit Parameters Using Property Inspector
To edit parameters that you cannot edit on the block icon, use the Property Inspector.
To edit a parameter using the Property Inspector:
Select the block.
Check if the Property Inspector is open.
If the Property Inspector window is not visible, check whether the right edge of the Simulink® window displays a Property Inspector tab.
If a tab is displayed, the Property Inspector is open and minimized. To expand the Property Inspector window, click the tab.
If no tab is displayed, the Property Inspector is closed. To open the Property Inspector, in the Simulink Toolstrip, on the Modeling tab, in the Design section, select Property Inspector.
In the Property Inspector, click the Parameters tab.
On the Parameters tab, find the name of the parameter whose value you want to edit.
Edit the parameter value in the corresponding text box.
Tip
To hide the Property Inspector, click the canvas. If the Property Inspector does not hide when you click the canvas, in the upper right-corner of the Property Inspector window, click the down arrow and select Minimize.
To show the Property Inspector again, click the Property Inspector tab.
Edit Parameters Using Block Parameters Dialog Box
To edit parameters that you cannot edit on the block icon, you can also use the Block Parameters dialog box.
To edit a parameter using the Block Parameters dialog box:
Double-click the block. The Block Parameters dialog box appears.
Find the name of the parameter whose value you want to edit.
Edit the parameter value in the corresponding text box. When you edit a parameter value, the text box turns yellow.
Click OK.
Specify Block Parameters as Variables
If you want to be able to edit the value of a parameter from the MATLAB® Command Window, a script, or the Workspace Browser, specify the value of the parameter as a variable or as an expression that contains variables. When you change the value of the variable, the value of the parameter also changes.
You can also use the set_param
function to edit the value from
the command window or a script. However, specifying the parameter as a variable makes your
code more compact. You also do not need to update your code when model or block names
change.
To specify the value of a parameter as a variable:
Initialize the variable in the MATLAB workspace (base, model, or mask) in which the parameter value is specified.
Change the parameter value to the name of the variable or to the variable expression.
Tip
When you set a block parameter value to a variable or function in the Block Parameters dialog box or the Property Inspector, Simulink provides a list based on the text you type. Instead of completely typing a variable name, you can type part of it and then select the full name from the list.
The list includes:
Variables and objects from every workspace (base, model, and mask)
Data dictionary
Referenced dictionary visible to the block parameter
Autocomplete is available for variables, for fields of structures and objects, and for functions on the MATLAB path.
When you specify the value of a parameter as a variable or variable expression, the Block Parameters dialog box and the Property Inspector display the value of the variable or the expression.
The text box where you enter the parameter value displays the variable or expression on the left and the value on the right.
To see the value the variable or expression has during simulation, run the simulation and open the Block Parameters dialog box or the Property Inspector. The displayed value is the value of the variable or expression in the simulation at the time step when you open the Block Parameters dialog box or the Property Inspector.
For more information, see View Values of Parameters Set as Variables.
Consider this example for how to specify the parameter values as variables:
A model contains a Constant block with a Constant
value of 1
that connects to a Display
block.
To specify the Constant value parameter value as the
variable expression 2*x+8
with x
initialized to a
value of 3
:
To initialize
x
, enter this command in the MATLAB Command Window.x=3;
To open the Block Parameters dialog box, in the Simulink model window, double-click the Constant block.
In the Block Parameters dialog box, set the Constant value to
2*x+8
. On the right side of the text box, the value of the variable expression2*x+8
is displayed.In the Block Parameters dialog box, click OK.
Run the model. The Display block shows a value of
14
.
To change the value of x
to -1
:
Enter this command in the MATLAB Command Window.
x=-1;
Run the model. The Display block now shows a value of
6
.
Batch Edit Parameter Values Using Model Data Editor
To edit the values of multiple parameters at once, use the Model Data Editor
or the Model Explorer.
Use the Model Data Editor to batch edit the core parameters of blocks, such as the
Gain parameter of Gain blocks or the
Constant Value parameter of Constant blocks. The
Model Data Editor does not show all block parameters. To batch edit parameters the Model
Data Editor does not show, use the Model Explorer. Alternatively, consider batch editing
programmatically using the set_param
function.
To batch edit using the Model Data Editor:
Open the Model Data Editor. In the Simulink Toolstrip, on the Modeling tab, in the Design gallery, select Model Data Editor. Alternatively, press Ctrl+Shift+E (on macOS, press command+shift+E).
Click the Parameters tab.
By default, the Model Data Editor only displays data for model elements in the current level of the model hierarchy. To edit parameter values of model elements that are not in the current level of the model hierarchy, change the scope of the displayed content to include all levels of the model hierarchy. Click the Change scope button .
Select the rows containing the parameter values you want to change. Use the Shift key to select multiple consecutive rows. Use the Ctrl key (on macOS, press command) to select multiple nonconsecutive rows.
To more easily identify rows, view these columns. For more information on the contents of the columns displayed in the Model Data Editor, see Columns in the Data Table.
Name – Programmatic name of a parameter
Source – Name of the block the parameter modifies
Path – Block path
If you have a large model, you can make rows easier to find by filtering the contents of the Model Data Editor.
To apply a filter to all columns, enter keywords in the Filter contents text box. To clear the filter, click the
X
to the right of the keywords.To apply a filter to a column, pause on the column header. Click the filter icon . Then, enter keywords in the text box. For example, to see only the parameter values of model elements in the
Controller
subsystem, pause on the Path column, click the filter icon, and then enterController
. To clear the filter for that column, click theX
to the right of the keyword. To clear the filters of all columns, select Clear all column filters.
For information on filtering, sorting, and grouping in the Model Data Editor, see Find and Organize Data by Filtering, Sorting, and Grouping.
Click a value you want to change.
Enter the new value and press Enter. The parameter values of all selected rows change to the new value.
Batch Edit Parameter Values Using Model Explorer
To edit the values of multiple parameters at once, use the Model Data Editor
or the Model Explorer.
Use the Model Data Editor to batch edit the core parameters of blocks such as the
Gain parameter of Gain blocks or the
Constant Value parameter of Constant blocks. The
Model Data Editor does not show all block parameters. To batch edit parameters the Model
Data Editor does not show, use the Model Explorer. Alternatively, consider batch editing
programmatically using the set_param
function.
To batch edit using the Model Explorer:
Open the Model Explorer. In the Simulink Toolstrip, on the Modeling tab, in the Design gallery, select Model Explorer. Alternatively, press Ctrl+H (on macOS, press command+H).
In the Model Hierarchy tree, select the model containing the blocks whose parameter values you want to change. If the blocks are in a specific component of the model hierarchy, expand the Model Hierarchy tree and select the component.
By default, the Model Explorer only displays data for model elements in the current level of the model hierarchy. To edit parameter values of model elements that are not in the current level of the model hierarchy, change the scope of the displayed content to include all levels of the model hierarchy. Click the Change scope button .
Under Column View, verify that Block Data Types is selected.
Find the column header with the name of the parameter whose values you want to change. For example, if you want to change the value of the Gain parameter, find the Gain column.
If the parameter name does not appear in a column header, add a column for the parameter. Click Show Details. In the Find Properties text box, enter the programmatic name of the parameter. Click the Display property as column in view button . A column displaying the values of the parameter you specified appears in the Contents pane. Click Hide Details.
Tip
To remove a column from view, click Show Details. Under Column Name, select the column header name. Click the Remove column from view button .
Select the rows containing the parameter values you want to change. Use the Shift key to select multiple consecutive rows. Use the Ctrl key (on macOS, press command) to select multiple nonconsecutive rows.
To more easily identify rows, view the name and type of the block the parameter modifies in the Name and Block Type columns. To view the block path, add a column for the Path parameter. Click Show Details. In the Find Properties text box, enter
Path
. Click the Display property as column in view button . Click Hide Details.If you have a large model, you can make rows easier to find by filtering the contents.
In the Filter Contents text box, enter keywords.
To only display model elements of a certain type, click the Show/Hide objects in contents pane button and select all types you want to display.
Click a value you want to change.
Enter the new value and press Enter. The parameter values of all selected rows change to the new value.
See Also
Property
Inspector | Model Data Editor | Model Explorer | get_param
| set_param