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 edit and manage workspace variables, use the Model Explorer. See Edit and Manage Workspace Variables by Using Model Explorer for details.

To get and set the values of parameters programmatically, see Programmatically Specify Block Parameters and Properties.

Edit Parameters on Block Icon

For these blocks, you can enter a new value for a parameter directly on the block icon:

To edit the parameter value on the block icon:

  1. Select the block.

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

  3. Enter a new value.

  4. Press Enter.

The block only displays the new value if the value fits on the block. If the block is too small, the block displays a placeholder letter instead, for example, -K-. To resize all blocks of the listed block types in a model to be large enough to display their values, use the Simulink.BlockDiagram.resizeBlocksToFitContent function.

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-

For these blocks, you can select a new value for a parameter on the icon from a list of enumerated values:

To edit the parameter value, select the block, click the value on the block icon, and then select a new value from the drop-down list using your pointer or arrow keys.

On the left is a Rounding Function block, and on the right is a Rounding Function block with the drop-down list of Function values expanded. The options are floor, ceil, round, and fix.

The Goto and From blocks are a special case of these blocks. Goto and From blocks are related blocks, which means they connect to each other without signal lines. Goto and From blocks with the same Goto tag value are connected.

  • To change Goto tag value of a Goto block, select the block, click the value on the icon, type a new value, and then press Enter. If the initial value is not selected by any From blocks in the model, the value gets replaced by the new value in the From drop-down lists.

    An Inport block connects to a Goto block with a signal line, and a From block connects to an Outport block with a signal line. The Goto tag of the From block is A, and on the Goto block, a new Goto value is being entered. The new value is B.

  • To change the Goto tag value of a From block, select the block, click the value on the block icon, and then select a new value from the drop-down list using your pointer or arrow keys.

    An Inport block connects to a Goto block with a signal line, and a From block connects to an Outport block with a signal line. The Goto tag of the Goto block is B, and on the From block, a new Goto value is being selected. The drop-down list is expanded, and the pointer is on the value B.

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 panel, 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.

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.

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

| | | |

Topics