Main Content

Format a Model

As you build a model, you can adjust block positions, change block colors, place block names and ports on any side of the block, adjust fonts, and add elements that help to improve model readability. These changes can help to organize the model visually and help others understand the model.

You can make these types of changes to your model format:

Improve Model Layout

To improve your diagram layout and appearance, in the Format tab, click Auto Arrange. This option:

  • Aligns blocks in your model from left to right, starting with inputs and ending with outputs

  • Resizes blocks, such as the Constant block, to display long parameter values

  • Standardizes block size among similar blocks

  • Straightens signal lines by moving blocks

Alternatively, you can try improving the shapes of individual signal lines. Select the signal line and, from the action bar, select Auto-route Line. The line redraws if a better route between model elements is possible.

You can try to improve multiple lines by using Auto-route Lines. To access Auto-route Lines from the action bar, select a block or select multiple model elements by dragging a box around the elements.

Move Multiple Model Elements Together

To move multiple model elements while maintaining their relationship with each other:

  1. Select the model elements by dragging a selection box around them.

  2. Move the model elements by dragging an edge of the selection box to a new position.

The contents of the selection box move as a unit. The relationship among lines, blocks, and other elements in the selection box remains the same as you move them. Line segments outside of the selection box reroute.

For example, suppose you have this model:

The model has multiple lines with bends.

When you drag a selection box that includes line bends, the included line bends remain the same when you move the selection.

Line routing inside the selection box remains the same during the move.

When you drag a selection box that excludes line bends, the excluded line bends may change when you move the selection.

Line routing external to the selection block changes during the move.

To move multiple lines together, drag the selection box around the line segments you want to move.

Multiple lines move together.

Flip or Rotate Blocks

You can change the orientation of a block or a group of blocks by rotating blocks in 90-degree increments or by flipping the blocks. Rotating or flipping blocks can help them fit better in the model, such as in feedback loops, where the blocks are connected to each other in a loop. You might also need to rotate a block so that the block input ports align with output ports or to make better use of the model canvas.

The figure shows a Gain block flipped to simplify a feedback loop diagram.

To rotate a block, select the block and, on the Format tab, click Rotate 90 clockwise Rotate 90 clockwise button or Rotate 90 counterclockwise Rotate 90 counterclockwise button.

Blocks automatically rotate when you place them on a signal line that has an orientation other than left to right. For example, if the signal goes from bottom to top and you place a block on it, the block rotates to align with the signal.

To flip a block, select the block and, on the Format tab, click Flip left-right Flip left-right button or Flip up-downFlip up-down button. You can flip a block horizontally or vertically based on the orientation of the block ports. For example, if the ports are on the sides, the block flips left to right.

To rotate or flip a group of blocks, select multiple blocks before rotating or flipping them. You can only flip groups of blocks to the left or right.

After you rotate or flip a group of blocks, you can improve the readability of the model by editing the signal lines. The Auto Arrange option might improve the appearance of signals. (For information on rotation with multiple ports, see Port Location After Rotating or Flipping.)

For example, suppose you rotate these selected blocks clockwise.

Block group select

After you rotate the blocks, the model might contain overlapping elements.

After block rotate

With the blocks and signals selected, on the Format tab, select Auto Arrange.

After auto arrange

Port Location After Rotating or Flipping

Rotating moves block ports from the sides to top and bottom or the reverse, depending on the placement of the ports. The resulting positions of the block ports depend on the block port rotation type.

Rotating can reposition the ports on some blocks to maintain left-to-right or top-to-bottom port numbering order. A block whose ports are reordered after a rotation has the default port rotation type. This policy helps to maintain the left-right and top-down block diagram orientation convention used in control system modeling applications. The figure shows the effect of clockwise rotation on a block with the default port rotation policy.

Default port rotation

A masked block can specify that ports keep their order after rotation (see Port rotation). These blocks have a physical port rotation type. This policy helps when designing blocks to use when modeling physical systems and other applications where diagrams do not have a preferred orientation. The figure shows the effect of clockwise rotation on a block with a physical port rotation type.

Physical port rotation

Flipping a block moves the ports to the opposite side of the block, creating a mirror image, regardless of port rotation type.

Manage Block Names and Ports

You can manage block names by displaying or hiding them and by changing their location on the block.

Note

Copying and pasting blocks whose names follow numeric order (Gain1, Gain2, and so on) creates names that follow standard sorting order conventions for ASCII characters. This sorting order can result in a sequence of numbers on the block names that is hard to understand. If the numbering scheme is important to you, name your blocks explicitly such that copying and pasting them creates names that follow a typical reading order. To do so, use a leading zero in the block names, for example Gain001, Gain002, and so on.

Hide or Display Block Names

The Simulink® Editor names blocks when you create them. The first occurrence of the block is the library block name, for example, Gain. The next occurrence is the block name with a number appended. Each new block increments the number, for example, Gain1, Gain2, and so on. These names are called automatic names. By default, the editor hides these names.

You can choose whether to hide or display block names. You can:

  • Display all automatic names. Select one or multiple blocks and, on the Format tab, select the button that says Auto Name, Name On, or Name Off depending on its current setting. Then, clear Hide Automatic Block Names.

  • Temporarily display a hidden automatic block name by selecting the block.

  • Name the block explicitly. The Hide Automatic Names setting does not affect blocks that you name explicitly. To name a block, select it, double-click the name, and type a new name.

In addition, you can explicitly hide or display any block name. Explicitly hidden or displayed block names are not affected by the Hide Automatic Block Names setting. To explicitly hide or display a block name, select the block, then on the Format tab, select the button that says Auto Name, Name On, or Name Off depending on its current setting. Then, select:

  • Name On to always display the block name.

  • Name Off to always hide the block name.

  • Auto Name to return to the default state. If the block has a default name, the Hide Automatic Block Names setting affects the block.

Tip

You can pause on a block to display the block name irrespective of the name settings at the block and model levels. You can edit the block name when it displays.

To display and hide block names programmatically, use set_param with the 'HideAutomaticNames' option for models and the 'HideAutomaticName' and 'ShowName' options for blocks. For more information on these parameters, see Common Block Properties. The table shows how these parameters interact.

'ShowName' (block setting)'HideAutomaticName' (block setting)'HideAutomaticNames' (model setting)Result
'off'AnyAnyName is hidden
'on''on''on'Name is hidden
'on''off'AnyName is shown
'on''on''off'Name is shown

Move Block Names

By default, block names appear below blocks whose ports are on the sides and to the left on blocks whose ports are on the top and bottom. To change the location of a block name, you can:

  • Drag the block name to any side of the block.

  • Select the block and, on the Format tab, click Flip Name.

Move Ports

You can put ports in any order on any side of these blocks:

You can move ports by clicking and dragging the port. For Subsystem blocks, the port index will automatically be renumbered after each move. For port label editing on Subsystem blocks, see Edit Port Labels on Subsystems.

Specify Model Colors

You can specify the outline and interior colors of any block, and you can change the background color for any system in a model. You can also change the text color and background color for annotations and the background fill color for areas.

This subsystem uses color to identify the input ports.

  • To change the outline color of a block, text color in an annotation, or interior color for an area, select the element, and then, on the Format tab, select a color from the Foreground menu. Changing the foreground color of a block also changes the color of its output signals.

  • To change the interior color of a block or background color in an annotation, select the element, and then, on the Format tab, select a color from the Background menu.

  • To change a background color in a system, open the system and, on the Format tab, select a color from the Background menu.

You can select a color from the menu or select Custom Color Custom Color button to define your own color.

You can also use the Property Inspector to change color for an area or an annotation. To specify colors programmatically, see Specify Colors Programmatically

Specify Fonts in Models

Change the font family, style, and size for any model element to make your model easier to read or to comply with company standards. You can modify the font for selected blocks, signal labels, areas, and annotations. Some blocks display text according to the font style settings, and some blocks have fixed fonts and styles. To increase the font size of those blocks, zoom in.

You can also change the default font for the model. The default font affects any elements whose font you have not changed and any new elements you create. If you want to use the same default font in all new models, change the default model font in your default template. See Set Default Template for New Models.

  • To change the font of a block, signal label, area, or annotation, select the element, and then specify font information on the Format tab in the Font & Paragraph section.

  • To change the default fonts for the model, on the Format tab, click the Font Properties button arrow Font Properties button arrow, then click Fonts for Model. Use the Font Styles dialog box to specify the font information.

You can also use the Property Inspector to change font for an area or an annotation.

Select Font Dialog Box on Linux Machines

On Linux® machines configured for English, the Font style list in the Select Font dialog box can appear out of order or in another language in some fonts. If the characters in your Font style list appear in another language, set the LANG environment variable to en_US.utf-8 before you start MATLAB®. For example, at a Linux terminal, enter:

setenv LANG en_US.utf-8 
matlab

Increase Drop Shadow Depth

By default, blocks have a drop shadow. To make the block stand out more against the background, you can increase the depth of the drop shadow.

Select the blocks whose drop shadow depth you want to increase and, on the Format tab, click Shadow.

Tip

To remove the default drop shadow for all blocks, in the Simulink Toolstrip, on the Modeling tab, select Environment > Simulink Preferences. In the Editor pane of the Simulink Preferences dialog box, select Use classic diagram theme.

Box and Label Areas of a Model

Add an area to your model to visually group related model elements in a box. An area can move with the blocks it surrounds. You can add text to an area to briefly describe or label the area.

  1. Drag a box around the area of interest in the model. Alternatively, drag on a blank area of the canvas to draw the area shape.

  2. From the action bar, select the option to create an area.

  3. Type the name of the area. The name appears in the upper-left corner of the area.

    To enter the name later, select the area, click the ?, and start typing, or use the Name property in the Property Inspector.

  4. Optionally, add a description of the area contents using the Property Inspector.

  5. To move the area and its contents, drag the area near the border.

    Tip

    To move an area without moving its contents, hold Alt (option on a Mac) and drag.

Convert Area to a Subsystem

An area is similar to a subsystem in that it is a way to group related blocks. However, a subsystem creates a hierarchy, replacing multiple blocks in a model with a single block. You can initially group related blocks in an area and later decide to put those blocks in a subsystem by converting the area to a subsystem. The resulting subsystem has the same name, blocks, description, and requirements traceability information as the area.

To convert an area to a subsystem, right-click the area and select Create Subsystem from Area.

Copy Formatting Between Model Elements

If you have applied formatting to a block, signal line, or area in a model, you can copy the formatting and apply it to another model element. Examples of formatting include font changes, foreground and background color selections, and drop shadow effects.

  1. Select the block, line, or area whose formatting you want to copy.

  2. From the action bar, select Copy Formatting. The cursor becomes a paintbrush.

  3. Using the paintbrush, click each element that you want to copy the formatting to.

  4. To cancel the paintbrush cursor, click a blank spot on the canvas or press Esc.

Related Topics