Main Content

Add Blocks and Set Parameters

Add Blocks to the Model

A basic model takes an input signal, operates on it, and outputs the result. In the Library Browser, in the Simulink® library, the Sources sublibrary contains blocks that represent different types of inputs. The Sinks sublibrary has blocks for capturing and displaying outputs. The other sublibraries contain blocks you can use for a variety of purposes, such as math operations.

In this example of a basic model, you use a sine wave for an input, multiply the signal value, and output the result. Try different techniques to explore the library and to add blocks to your model.

  1. Open the Library Browser in docked mode. In the Simulink Toolstrip, on the Simulation tab, click the Library Browser button.

  2. In the tree view of the Library Browser, expand the Simulink library, then expand the Sources sublibrary.

  3. In the Sources sublibrary, pause on the Sine Wave block to see a tooltip describing its purpose.

  4. Add a block to your model using the context menu. Right-click the Sine Wave block and select Add block to model. To learn more about the block, right-click the block and select Help.


    If the blocks are in the single-column layout, to make the block easier to click, you can switch to the responsive layout, which has larger block icons. To switch, on the Library Browser, click the Responsive layout button Responsive layout button.

  5. Add a block to your model by dragging. In the library tree view, in the Simulink library, expand the Math Operations sublibrary. In the Math Operations sublibrary, locate the Gain block and drag it to your model to the right of the Sine Wave block.

  6. In the Simulink library, expand the Sinks sublibrary, locate the Scope block and add it to your model using the context menu or by dragging it.

    The figure shows your model so far.

    Three unconnected blocks in the model canvas: a Sine Wave block (left), a Gain block with a value of one (center), and Scope block (right)


The Simulink Editor names blocks as you add them. For example, it names the first Gain block that you add Gain, the next Gain1, and so on. By default, the Simulink Editor hides these names. However, you can see the name by selecting the block. To make block names visible, you can:

  • Name the block.

  • Select the block. On the Format tab, select Auto Name > Name On.

  • Change the model setting for displaying block names. On the Debug tab, select Information Overlays and clear Hide Automatic Block Names.

For more information on displaying block names, see Manage Block Names and Ports.

Align and Connect Blocks

Connect the blocks to create relationships between model elements to make the model operate. Reading the model is easier when you line up blocks according to how they interact with each other. Shortcuts help you to align and connect blocks.

  1. Drag a Gain block so it lines up with the Sine Wave block. An alignment guide appears when the blocks line up horizontally.

  2. Release the block, and a blue arrow appears to suggest a connection.

    An unconnected Sine Wave block (left), a selected, unconnected Gain block with a value of one (right), and between them, a transparent blue arrow that points from the former to the latter

  3. To make the connection, click the arrow. A solid line appears.

  4. Line up and connect the Scope block to the Gain block using the same technique. Additional guides appear when multiple blocks are within range.

    Three blocks in the model canvas that are equally spaced in the horizontal direction, with the respective distances between each of the two outer blocks and the center block indicated by transparent blue dimension lines

  5. To connect the Gain block to the Scope block, drag a line from the output port of the Gain block to the input port of the Scope block.


For additional alignment options, select multiple blocks. On the Format tab, click options in the Align section.

Set Block Parameters

You can set parameters on most blocks. Parameters allow you to specify how a block operates in the model. You can use the default values or set your own values in these ways:

  • Use the Property Inspector to set parameters.

  • Double-click most blocks to set the parameters using the Block Parameters dialog box.

  • Edit block parameter values on the block icon. See Edit Block Parameters on Block Icons.

In your model, set the sine wave amplitude.

  1. Display the Property Inspector. On the Modeling tab, under Design, click Property Inspector.

  2. Select the Sine Wave block.

  3. In the Property Inspector, set the Amplitude parameter to 2.

In a block dialog box or in the Property Inspector, when you set a block parameter value to a variable or function, Simulink provides a list based on the current text typed in the edit field. The suggestions include variables or objects from every workspace (base, model, and mask), data dictionary, and referenced dictionary visible to the block parameter. Autocomplete is available for variables, fields of structures and objects, and for functions on the MATLAB® path.

Edit Block Parameters on Block Icons

For blocks that display parameter value on the block icon, you can edit the value interactively on the icon.

In your model, edit the gain value.

  1. Select the Gain block. Pause on the block. A blue underline appears under the parameter value, which indicates that the parameter is editable.

  2. Set the Gain parameter to 300000. Click the underlined number, delete it, and enter 300000.

    The new value exceeds the boundaries of the Gain block.

    Blocks such as Constant and Gain blocks display a parameter value only when it fits on the block icon.

  3. To resize the block so that it displays the parameter value, click the interactive cue.

    The interactive cue shows the size the block must be to display the parameter value.

    Alternatively, use one of these options to resize the block so that it displays the parameter value:

    • In the Simulink Toolstrip, on the Format tab, select Fit to Content.

    • In the Simulink Editor, on the action bar that appears when you select the block and pause on the ellipsis, select Fit to Content.

You can also edit enumerated block parameter values on the block icon.

  • Fixed parameter enumeration — For the block parameters that have a fixed set of values, you can select the value from a list of allowed values using the cursor or arrow keys.

    For example, consider a Rounding Function block that allows a list of values for the Function parameter.

    1. Select the block and point to the block icon. The editable parameter value appears underlined.

      Edit block parameter on block icon

    2. Click the underlined text to edit the value. A list appears with allowed values for the Function parameter. Select the required value from the list to update the block parameter value.

      List of fixed parameter values shown on the block icon

    This feature is enabled for these blocks:

  • Dynamic parameter enumeration — For block parameters that allows dynamic values, you can select a value from the list, or you can type the new value. Typing a new value removes unmatched values from the list.

    The feature is currently enabled for the From block.

    For example, consider a From block with three values for the GoTo Tag parameter.

    List of dynamic parameter values shown on the block icon

    Updated From tag shown on the block icon

See Also

| | | |

Related Topics