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, the Sources library contains blocks that represent different types of inputs. The Sinks library has blocks for capturing and displaying outputs. The other libraries 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.
In the Simulink® Toolstrip, on the Simulation tab, open the Library Browser.
In the tree view of the Library Browser, click the Sources library.
In the right pane, pause on the Sine Wave block to see a tooltip describing its purpose.
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.
Add a block to your model by dragging. In the library tree view, click Math Operations. In the Math Operations library, locate the Gain block and drag it to your model to the right of the Sine Wave block.
In the library tree view, click Simulink to view the sublibraries in the right pane. This view is an alternative way to navigate the library structure. Double-click the Sinks library icon.
In the Sinks library, 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.
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.
Drag a Gain block so it lines up with the Sine Wave block. An alignment guide appears when the blocks line up horizontally.
Release the block, and a blue arrow appears to suggest a connection.
To make the connection, click the arrow. A solid line appears.
Line up and connect the Scope block to the Gain block using the same technique. Additional guides appear when multiple blocks are within range.
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.
Display the Property Inspector. On the Modeling tab, under Design, click Property Inspector.
Select the Sine Wave block.
In the Property Inspector, set the Amplitude parameter to
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.
Select the Gain block. Pause on the block. A blue underline appears under the parameter value, which indicates that the parameter is editable.
Set the Gain parameter to
300000. Click the underlined number, delete it, and enter
Blocks such as Constant and Gain blocks display a parameter value only when it fits on the block icon.
To resize the block so that it displays the parameter value, click the interactive cue.
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.
Select the block and point to the block icon. The editable parameter value appears underlined.
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.
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.