| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
| On this page… |
|---|
As you build your model, you often copy blocks from Simulink block libraries or other libraries or models into your model window. To do this:
Drag the block to copy into the target model window. To drag a block, position the cursor over the block, then press and hold down the mouse button. Move the cursor into the target window, then release the mouse button.
You can also drag blocks from the Simulink Library Browser into a model window. See Browsing Block Libraries for more information.
Note The names of Sum, Mux, Demux, Bus Creator, and Bus Selector blocks are hidden when you copy them from the Simulink block library to a model. This is done to avoid unnecessarily cluttering the model diagram. (The shapes of these blocks clearly indicate their respective functions.) |
You can also copy blocks by using the Copy and Paste commands from the Edit menu:
Simulink assigns a name to each copied block. If it is the first block of its type in the model, its name is the same as its name in the source window. For example, if you copy the Gain block from the Math library into your model window, the name of the new block is Gain. If your model already contains a block named Gain, Simulink adds a sequence number to the block name (for example, Gain1, Gain2). You can rename blocks; see Manipulating Block Names.
When you copy a block, the new block inherits all the original block's parameter values.
For more ways to add blocks, see Adding Blocks.
add blocks
To move a single block from one place to another in a model window, drag the block to a new location. Simulink automatically repositions lines connected to the moved block.
To move more than one block, including connecting lines:
Select the blocks and lines. If you need information about how to select more than one block, see Selecting Multiple Objects.
Drag the objects to their new location and release the mouse button.
To move a block, disconnecting lines:
You can also move a block by selecting the block and pressing the arrow keys.
Moving blocks from one window to another is similar to copying blocks, except that you hold down the Shift key while you select the blocks.
You can use the Undo command from the Edit menu to remove an added block.
You can use tools to manually align blocks. These tools include a grid snap feature and smart guides that indicate when a block center or port aligns with the center or port of another block. You can also use commands that align a group of blocks automatically (see Aligning, Distributing, and Resizing Groups of Blocks Automatically for details).
Grid Snap. Simulink uses an invisible five-pixel grid to simplify the alignment of blocks. When you move a block to a new location, the block snaps to the nearest line on the grid. You can display the grid and change its spacing.
To display the grid, enter the following command at the MATLAB command prompt.
set_param('<model name>','showgrid','on')
The default width of the grid is 20 pixels. To change the grid spacing, enter
set_param('<model name>','gridspacing',<number of pixels>)
For example, to change the grid spacing to 25 pixels, enter
set_param('<model name>','gridspacing',25)
Note The new spacing must be a multiple of five pixels to ensure that the displayed grid aligns with the invisible snap grid. |
For either of the above commands, you can also select the model, then enter gcs instead of <model name>.
Smart Guides. When you move a block, smart guides appear by default to indicate when the block ports, center, or edges are aligned with the ports, centers, and edges of other blocks in the same diagram. For example, the following figure shows a snapshot of a Gain block that you drag from one position in a diagram to another. The dotted outline indicates the position to which the Gain block has been dragged. The blue smart guides indicate that if you drop the Gain block at this position, its left edge will be aligned with the left edge of the Subsystem block and its output port will be aligned with the input port of the Mux block.

When you drag a block, one of its alignment features, for example, a port, may match more than one alignment feature of another block. In this case, Simulink displays a line for one of the features, using the following precedence order: ports, centers, edges. For example, in the following drag-and-drop snapshot, the Gain block's center aligns with the Subsystem's center and the Gain block's output port aligns with the Mux block's input port. However, because ports take precedence over centers, Simulink draws a guide only for the ports.

You can turn smart guides off or on (the default) by selecting Format > Smart Guides.
You can position (and resize) a block programmatically, using its Position parameter. For example, the following command
set_param(gcb, 'Position', [5 5 20 20]);
moves the currently selected block to a location 5 points down and 5 points to the right of the top left corner of the block diagram and sets the block's height and width to 15 points, respectively.
Note The maximum size of a block diagram's height and width is 32767 points. An error message appears if you try to move or resize a block to a position that exceeds the diagram's boundaries. |
You can copy blocks in a model as follows. While holding down the Ctrl key, select the block with the left mouse button, then drag it to a new location. You can also do this by dragging the block using the right mouse button. Duplicated blocks have the same parameter values as the original blocks. Sequence numbers are added to the new block names.
Note The model editor sorts block names alphabetically when generating names for copies pasted into a model. This action can cause the names of pasted blocks to be out of order. For example, suppose you copy a row of 16 gain blocks named Gain, Gain1, Gain2...Gain15 and paste them into the model. The names of the pasted blocks occur in the following order: Gain16, Gain17, Gain24...Gain23. |
To delete one or more blocks, select the blocks to be deleted and press the Delete or Backspace key. You can also choose Clear or Cut from the Edit menu. The Cut command writes the blocks into the clipboard, which enables you to paste them into a model. Using the Delete or Backspace key or the Clear command does not enable you to paste the block later.
You can use the Undo command from the Edit menu to replace a deleted block.
![]() | Adding Blocks | Working with Block Parameters | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |