Main Content

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:

  1. Select the block.

  2. Click on the parameter value on the block icon.

  3. Enter a new value.

  4. Press Enter.

    Note

    The block icon only displays the new value if the value fits on the icon.

    On the left, a gain value of 1000 being entered on the icon of a Gain block, and on the right, the Gain block icon shows the text -K-

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:

    1. Select the Rounding Function block.

    2. Point to the block icon. The editable parameter value appears underlined.

    3. Click the underlined text to edit the value. A list with Function parameter values appears.

    4. 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 values sensor_A, sensor_B, and sensor_C.

    There are three Sine Wave blocks, each connected to a Goto block. To the right of these blocks, a From block connects to a Gain block with a value of 5, which connects to a Scope block. The Goto block with the Goto tag value sensor_A is selected, and the From block is highlighted in purple.

    To change the Goto Tag parameter value of the highlighted Goto and From block pair to a new value:

    1. Select a Goto block, and then click the text on the block icon.

    2. Enter a new name for the tag.

      Sine Wave block connected to a Goto block, and on the Goto block icon, the Goto tag parameter value new is displayed

    3. Press Enter.

    4. Select the From block.

    5. Click the text on the block icon. A list with Goto tag parameter values appears.

      A From block connects to a Gain block, which connects to a Scope block. A list with Goto tag parameter values expands from the From block icon. The values in the list are new, sensor_B, and sensor_C.

    6. 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:

  1. Select the block.

  2. 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.

  3. In the Property Inspector, click the Parameters tab.

  4. On the Parameters tab, find the name of the parameter whose value you want to edit.

  5. 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.

The Property Inspector for a Ramp block is open to the Parameters tab. The Slope is set to 2 and the Start time is set to 3. The Property Inspector tab at the right edge of the Simulink window is labeled with the text "Click to Expand Property Inspector Window".

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:

  1. Double-click the block. The Block Parameters dialog box appears.

  2. Find the name of the parameter whose value you want to edit.

  3. Edit the parameter value in the corresponding text box. When you edit a parameter value, the text box turns yellow.

  4. Click OK.

Block Parameters dialog box for Ramp block with the Slope set to 2, the Start time set to 3, and the Slope and Start time text boxes are yellow

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:

  1. Initialize the variable in the MATLAB workspace (base, model, or mask) in which the parameter value is specified.

  2. 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.

The value of the variable called x is 40. In the Block Parameters dialog box of a Gain block, the text box for entering the Gain value contains the expression "x+7" at the inner left edge, and the number 47 at the right edge.

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.

Constant block with a 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:

  1. To initialize x, enter this command in the MATLAB Command Window.

    x=3;
  2. To open the Block Parameters dialog box, in the Simulink model window, double-click the Constant block.

  3. 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 expression 2*x+8 is displayed.

    In the Block Parameters dialog box of the Gain block, the text box for entering the Gain value contains the expression "x-1" at the inner left edge, and the number 2 at the right edge.

  4. In the Block Parameters dialog box, click OK.

  5. Run the model. The Display block shows a value of 14.

    A Constant block with a value of 2*x+8 connects to a Display block. The Display block displays a value of 14.

To change the value of x to -1:

  1. Enter this command in the MATLAB Command Window.

    x=-1;
  2. Run the model. The Display block now shows a value of 6.

    A Constant block with a value of 2*x+8 connects to a Display block. The Display block displays 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:

  1. 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).

  2. Click the Parameters tab.

    Model Data Editor with the Parameters tab open

  3. 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 .

  4. 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 enter Controller. To clear the filter for that column, click the X 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.

    The Path column filter is expanded, and the keyword Controller is entered. The Model Data Editor displays parameters with the word Controller in their path.

  5. Click a value you want to change.

  6. Enter the new value and press Enter. The parameter values of all selected rows change to the new value.

In the Model Data Editor, the pointer selects the rows displaying data for three Gain blocks. In the Value column, the pointer clicks one of the values. A value of 2 is entered. The Gain value of all selected rows changes to 2.

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:

  1. 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).

  2. 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.

    Model Hierarchy tree with the f14 model selected

  3. 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 .

    In the Model Explorer, the Change scope button is highlighted.

  4. Under Column View, verify that Block Data Types is selected.

    In the Model Explorer, the Column View drop-down list is highlighted.

  5. 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.

    In the Model Explorer, the header of the Gain column is highlighted.

    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 .

    Adding a column for Multiplication parameter to the displayed contents of the Model Explorer

  6. 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.

    In the Model Explorer, the displayed contents include the Path column and are filtered using the keyword Gain.

  7. Click a value you want to change.

  8. Enter the new value and press Enter. The parameter values of all selected rows change to the new value.

In the Model Explorer, the pointer selects the rows displaying data for nine Gain blocks. In the Multiplication column, the pointer clicks one of the values and selects Matrix(u*K) . The Multiplication value of all selected rows changes to Matrix(u*K). In the Gain column, the pointer clicks one of the values. A value of 2 is entered. The Gain value of all selected rows changes to 2.

See Also

| | | |

Related Topics