Documentation Center

  • Trials
  • Product Updates

Edit Blocks

Copy Blocks in a Model

To copy a blocks in a model:

  1. In the Simulink® Editor, select the block.

  2. Press right mouse button.

  3. Drag the block to a new location and release the mouse button.

You can also do this by using the Ctrl key:

  1. In the Simulink Editor, press and hold the Ctrl key.

  2. Select the block with the left mouse button.

  3. Drag the block to a new location and release the mouse button.

Copies of blocks have the same parameter values as the original blocks. Sequence numbers are added to the new block names.

    Note:   Simulink 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, Gain18...Gain31.

Copy Blocks Between Windows

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:

  1. Open the appropriate block library or model window.

  2. 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 Browse 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 Simulink Editor:

  1. Select the block you want to copy.

  2. Select Edit > Copy.

  3. Make the target model window the active window.

  4. Choose Edit > Paste.

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 Manipulate 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 Add Blocks.

add blocks

Move 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:

  1. Select the blocks and lines. For information about how to select more than one block, see Select Multiple Objects.

  2. Drag the objects to their new location and release the mouse button.

To move a block, disconnecting lines:

  1. Select the block.

  2. Press the Shift key, then drag the block to its new location and release the mouse button.

You can also move a block by selecting the block and pressing the arrow keys.

You cannot move a block between:

  • Multiple systems open in one Simulink Editor instance

  • Systems open in multiple Simulink Editor instances

    If you drag a block between Simulink Editor instances, the block is copied to the target Simulink Editor model window.

Align Blocks

You can manually align blocks. You can also use commands that align a group of blocks automatically (see Align, Distribute, and Resize Groups of Blocks for details).

Smart Guides.  You can enable smart guides to help you align blocks and lines. When you move a block, smart guides appear to indicate when the block ports, center, or edges are aligned with the ports, centers, and edges of other blocks in the same diagram.

To display smart guides, in the Simulink Editor, select View > Smart Guides. The setting applies to all open instances of the Simulink Editor.

For example, the following figure shows a snapshot of a Gain block that you drag from one position in a diagram to another. The blue smart guides indicate that if you drop the Gain block at this position, its left edge is aligned with the left edge of the Subsystem block and its output port is aligned with the input port of the Saturation 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 center aligns with the Subsystem block center and the Gain block output port aligns with the Saturation block input port. However, because ports take precedence over centers, Simulink draws a guide only for the ports.

Position Blocks Programmatically

You can position (and resize) a block programmatically, using its Position parameter. For example, the following command:

set_param(gcb, 'Position', [10 20 30 50]);

moves the currently selected block to a position where the top left corner of the block is at 10 20, and the bottom right corner is at 30 50.

    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.

Delete Blocks

To delete one or more blocks, select the blocks to be deleted and press the Delete or Backspace key.

As an alternative, you can select Edit > ClearClear or Edit > Cut.

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.

To replace a deleted block, use the Edit > Undo command.

Comment Blocks

Comment out blocks in your model if you want to exclude them during simulation. To exclude a block, right-click the selected block and select Comment out. You can comment through blocks in a model, if you want them to be a pass through. Right-click the block and select Comment Through. You can only comment through blocks that have the same number of inports and outports.

Commenting blocks may be useful for several tasks, such as:

  • Incrementally testing parts of a model under development.

  • Debugging a model without having to delete and restore blocks between simulation runs.

  • Testing and verifying the effects of certain model blocks on simulation results.

  • Improving simulation performance.

You can comment Model Variant and Variant Subsystem blocks. However, you cannot comment the following:

  • Variant choices within a Variant Subsystem block.

  • Port Blocks, Iterator blocks, Data Store Memory, and Goto Tag Visibility blocks.

Was this topic helpful?