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 the model layout. SeeImprove Model Layout.
Flip or rotate blocks or groups of blocks. These adjustments help blocks to fit in the model and connect with other blocks. SeeFlip or Rotate Blocks.
Reposition or hide block names, edit port labels, and move ports to any side of the block. SeeManage Block Names and Ports.
Add colors to blocks and to the background. SeeSpecify Model Colors.
Adjust aesthetics by changing fonts and deepening the intensity of drop shadows. SeeSpecify Fonts in ModelsandIncrease Drop Shadow Depth.
Surround groups of blocks with a box to show that the blocks are related. SeeBox and Label Areas of a Model.
Copy formatting from a block, line, or area to another model element. SeeCopy Formatting Between Model Elements.
文档模型使用文本、图片和数学annotations. SeeDescribe Models Using Notes and Annotations.
Annotate a block. SeeSet Block Annotation Properties.
Change the block icon. For example, you can use a mask to display a graphic on a block. A mask also enables you to design a custom interface for a block. To learn about masks, seeMasking Fundamentals.
Improve Model Layout
To improve your diagram layout and appearance, on theFormattab, clickAuto Arrange, or, pressCtrl+Shift+A. This option:
Aligns blocks in your model from left to right, starting with inputs and ending with outputs
Resizes blocks, such as theConstantblock, to display long parameter values
标准化之间的块大小相似的块
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, selectAuto-route Line. The line redraws if a better route between model elements is possible.
You can try to improve multiple lines by usingAuto-route Lines. To accessAuto-route Linesfrom 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:
Select the model elements by dragging a selection box around them.
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:
When you drag a selection box that includes line bends, the included line bends remain the same when you move the selection.
When you drag a selection box that excludes line bends, the excluded line bends may change when you move the selection.
To move multiple lines together, drag the selection box around the line segments you want to move.
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 aGainblock flipped to simplify a feedback loop diagram.
To rotate a block, select the block and, on theFormattab, click theRotate 90 clockwisebuttonor theRotate 90 counterclockwisebutton.
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 theFormattab, clickFlip left-rightbuttonorFlip up-downbutton. 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. TheAuto Arrangeoption might improve the appearance of signals. (For information on rotation with multiple ports, seePort Location After Rotating or Flipping.)
For example, suppose you rotate these selected blocks clockwise.
After you rotate the blocks, the model might contain overlapping elements.
With the blocks and signals selected, on theFormattab, selectAuto 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 blockport 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 thedefault port rotationtype. 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.
A masked block can specify that ports keep their order after rotation (seePort rotation). These blocks have aphysical port rotationtype. 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.
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 calledautomatic 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 theFormattab, select the button that saysAuto Name,Name On, orName Offdepending on its current setting. Then, clearHide Automatic Block Names.
Temporarily display a hidden automatic block name by selecting the block.
Name the block explicitly. TheHide Automatic Namessetting 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 theHide Automatic Block Namessetting. To explicitly hide or display a block name, select the block, then on theFormattab, select the button that saysAuto Name,Name On, orName Offdepending on its current setting. Then, select:
Name Onto always display the block name.
Name Offto always hide the block name.
Auto Nameto return to the default state. If the block has a default name, theHide Automatic Block Namessetting 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, useset_param
with the'HideAutomaticNames'
option for models and the'HideAutomaticName'
and'ShowName'
options for blocks. For more information on these parameters, seeCommon Block Properties. The table shows how these parameters interact.
'ShowName' (block setting) |
'HideAutomaticName' (block setting) |
'HideAutomaticNames' (model setting) |
Result |
---|---|---|---|
'off' |
Any | Any | Name is hidden |
'on' |
'on' |
'on' |
Name is hidden |
'on' |
'off' |
Any | Name 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 theFormattab, clickFlip Name.
Move Ports
You can put ports in any order on any side of these blocks:
Subsystemblock
Subsystem Referenceblock
Modelblock
Chart(Stateflow)block
Truth Table(Stateflow)block
State Transition Table(Stateflow)block
你可以移动港口通过点击和拖动port. ForSubsystemblocks, the port index will automatically be renumbered after each move. For port label editing onSubsystemblocks, seeEdit 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 theFormattab, select a color from theForegroundmenu. 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 theFormattab, select a color from theBackgroundmenu.
To change a background color in a system, open the system and, on theFormattab, select a color from theBackgroundmenu.
You can select a color from the menu or select theCustom Colorbuttonto define your own color.
You can also use the Property Inspector to change color for an area or an annotation. To specify colors programmatically, seeSpecify 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.
您还可以更改默认字体为模型. 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. SeeSet 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 theFormattab in theFont & Paragraphsection.
To change the default fonts for the model, on theFormattab, click theFont Propertiesbutton arrow, then clickFonts 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 onLinuxMachines
On Linux®machines configured for English, theFont stylelist in the Select Font dialog box can appear out of order or in another language in some fonts. If the characters in yourFont stylelist appear in another language, set theLANG
environment variable toen_US.utf-8
before you start MATLAB®. For example, at a Linux terminal, enter:
setenvLANGen_US.utf-8matlab
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 theFormattab, clickShadow.
Tip
To remove the default drop shadow for all blocks, in the Simulink Toolstrip, on theModelingtab, selectEnvironment>Simulink Preferences. In theEditorpane of the Simulink Preferences dialog box, selectUse 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.
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.
From the action bar, select the option to create an area.
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 theNameproperty in the Property Inspector.
Optionally, add a description of the area contents using the Property Inspector.
To move the area and its contents, drag the area near the border.
Tip
To move an area without moving its contents, holdAlt(optionon 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 selectCreate 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.
Select the block, line, or area whose formatting you want to copy.
From the action bar, selectCopy Formatting. The cursor becomes a paintbrush.
Using the paintbrush, click each element that you want to copy the formatting to.
To cancel the paintbrush cursor, click a blank spot on the canvas or pressEsc.