Extend the Model and Create Subsystems
Add More Blocks
Suppose that you want to multiply the absolute value of the output from the Sine Wave block. To do this, you can add an Abs block and another Gain block to the model by using different techniques to locate and add blocks.
If you know the name of the block that you want to add, you can use the quick insert menu. Double-click where you want to add the block, and type the block name. In this case, enter
The suggestions are dynamically ranked based on your recent block usage history.
Click the block name or, with the block name highlighted, press Enter. You can use the arrow keys to highlight the block name if it is not first in the list.
Some blocks display a prompt for you to enter a value for one of the block parameters. The Gain block prompts you to enter the Gain value. Type
3and press Enter.
To perform an absolute value, add an Abs block. Suppose you do not know the library a block is in or the full name of the block. You can search for it using the search box in the Library Browser. Open the Library Browser. In the search box, type
absand press Enter. When you find the Abs block, add it to the left of the new Gain block.
Add another Scope block. You can right-click the existing Scope block and drag to create a copy or use the Copy and Paste commands.
The figure shows the current state of the model.
Branch a Connection
The input to the second Gain block is the absolute value of the output from the Sine Wave block. To use a single Sine Wave block as the input to both gain operations, create a branch from the Sine Wave block output signal.
For the first set of blocks in your model, you used the horizontal alignment guides to help you align and connect them. You can also use guides to align blocks vertically. Drag the second Scope block so that it lines up under the first one. Release it when the vertical alignment guide shows that the blocks are aligned.
You can click a port to identify compatible ports that can be connected to it. The port hint symbol appears near the compatible elements.
Click the output port of the Gain block.
Point to to see the connection cue.
Click the cue to connect the Gain block to the Scope block.
Connect the output port of the Abs block to the input port of the Gain block.
Create a branch from the Sine Wave block output to the Abs block. Click the input port of the Abs block. Move the cursor toward the output signal line from the Sine Wave block. A preview line appears. Click to create the branch.
Alternatively, you can start the branch by clicking the line segment and then moving the cursor toward the port.
Name the signals. Double-click the signal line between the bottom Gain block and Scope block and type
Scope. The label appears next to the signal line.
Try these methods to add or connect blocks:
To get a list of recommended blocks to connect to an unconnected signal line, drag from a block port and release so that a red, dotted line appears. Double-click the end of the line to use the quick insert menu. Suggested blocks for the current context appear on the menu. You can select one of the listed blocks.
To improve the menu suggestions based on your model designs, see Improve Quick Block Insert Results.
To search for a block by name, double-click the canvas and then type the name of a block to get a list of blocks that starts with the characters you typed. For custom library blocks, you can type the block keyword, if the library author assigned one. The list is ranked based on your recent block usage history.
To connect one port to multiple blocks, click a port, then hold Shift before you click another port. Holding Shift lets you make multiple, consecutive connections. For example, while holding Shift, you can branch a new signal line and connect it to another port or signal line with one click.
To connect blocks, select the first block and Ctrl+click the block you want to connect it to. This technique is useful when you want to connect blocks that have multiple inputs and outputs, such as multiple blocks to a bus or two subsystems with multiple ports. As with clicking two ports, this technique is useful when you do not want to align blocks. The signal line bends as needed to make the connection.
To make a diagonal line from line segments, press Shift and drag a vertex.
To improve the shape of a signal line, select the line and pause on the ellipsis that appears. From the action bar, select Auto-route Line. The line redraws if a better route between model elements is possible. To improve line routing for a selected block or for multiple model elements selected by dragging a selection box, select Auto-route Lines from the action bar.
Organize Your Model into Components
You can group blocks in subsystems and label blocks, subsystems, and signals. For more information about subsystems, see Create Subsystems.
Drag a selection box around the Abs block and the Gain block next to it.
Move the cursor over the ellipsis that appears at the corner of the selection box. From the action bar, select Create Subsystem.
A Subsystem block appears in the model in place of the selected blocks. On the Subsystem block icon, labels describe the input and output ports by index or name.
You can place a port on any side of the Subsystem block. To move a port, click and drag it around the block.
To resize the Subsystem block for the best fit in your model, drag the block handles.
Give the subsystem a meaningful name. Select the block, double-click the name, and type
Absolute Value. Naming a block causes the name to appear in the model.
Open the Absolute Value subsystem by double-clicking it. Alternatively, right-click the subsystem and select Open in New Tab.
The subsystem contains the blocks and signal that you selected as the basis of the subsystem. They are connected in sequence to two new blocks: an Inport block and an Outport block. Inport and Outport blocks correspond to the input and output ports on the subsystem. Creating the subsystem from a selection that includes a named signal adds the name of the signal to the corresponding Inport or Outport block.
Click the Up to Parent button to return to the top level of the model.
You can use the Explorer Bar to navigate the model hierarchy. For example, to return to the parent model, click the name of the parent model.
The figure shows the model after you create the subsystem and name it.