Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

配置模型布局

您可以通过更改模型元素的位置和方向来组织模块图。

  • 您可以通过拖动信号线来移动它们。

  • 您可以移动、旋转和翻转模块。

  • 对于某些模块(如 Subsystem 模块),您可以更改端口顺序。

您可以手动更改模块图布局,也可以让软件为您安排。

有关如何将模块组织到子系统中的信息,请参阅将模块组合为子系统。有关如何捆绑信号线的信息,请参阅将信号或消息组合到虚拟总线中

通过自动排列改进模型布局

要改进您的图布局和外观,请在格式选项卡上,点击自动排列

提示

或者,按 Ctrl+Shift+A

此选项:

  • 从左向右对齐模块图中的模块,从输入开始,以输出结束

  • 调整模块的大小,例如 Constant 模块,以显示长参数值。

  • 标准化相似模块间的模块大小。

  • 通过移动模块来拉直信号线。

您还可以以编程方式自动排列模型中的模块图。

  1. 使用 load_system 函数加载模型。

  2. 使用 Simulink.BlockDiagram.arrangeSystem 函数自动排列模块图。

您也可以尝试改进各信号线的形状。选择信号线,并从操作栏中选择自动布线。如果模型元素之间存在更好的路线,则会重新绘制信号线。

您可以尝试使用自动布线改进多条信号线。要从操作栏访问自动布线,请选择模块或通过在元素周围拖动绘制一个框来选中多个模型元素。

同时移动多个模型元素

要移动多个模型元素,同时保持其空间关系,请执行以下操作:

  1. 通过在模型元素周围拖动绘制一个选择框来选中模型元素。

  2. 通过拖动选择框的边并将其挪至新位置来移动模型元素。

选择框中的内容将作为一个整体移动。在移动选择框中的信号线、模块和其他元素时,它们之间的关系保持不变。选择框外的线段会重排。

以如下模型为例。

The model contains two subsystems that connect to two Outport blocks with multiple signal lines. The signal lines pass through Bus Creator blocks. Two of the lines have bends.

当拖动包含弯曲信号线的选择框时,其包含的弯曲信号线保持不变。

A selection box is drawn around two Bus Creator blocks, two Outport blocks, and part of the signal lines entering these blocks, including multiple line bends. The content of the selection box is moved to the right, but the line routing inside the selection box is unchanged.

当拖动不包含弯曲信号线的选择框时,被排除的弯曲信号线可能在您移动所选内容时更改。

The selection box is drawn around the same blocks as before, but not around the bends in the signal lines entering the blocks. The content of the selection box is moved to the right. The line bends are changed.

要一起移动多个信号线,请在要移动的线段周围拖动以形成一个选择框。

A selection box is drawn around two line segments in the model.

翻转或旋转模块

通过以 90 度为增量旋转或翻转模块,您可以更改模块或模块组的方向。旋转或翻转模块可以帮助它们更好地适应模块图,例如在反馈回路模型中,模块相互连接形成回路。您也可能需要旋转一个模块,以使模块输入端口与输出端口对齐或更好地使用模型画布。

下图显示了为了简化反馈回路图而翻转的 Gain 模块。

Feedback loop diagram with one of the gain blocks flipped horizontally

要旋转模块,请选择该模块。在格式选项卡上,点击顺时针旋转 90° 或逆时针旋转 90°

提示

或者:

  • 要顺时针旋转模块,请按 Ctrl+R

  • 要逆时针旋转模块,请按 Ctrl+Shift+R

当将模块放置在非从左向右的信号线上时,模块将自动旋转。例如,如果信号从底部到顶部传输,并且您在其上放置模块,则模块会旋转使其与信号对齐。

要翻转模块,请选择该模块,然后在格式选项卡上,点击左右翻转 或上下翻转 。您可以根据模块端口的方向水平或垂直翻转模块。例如,如果端口在两侧,则从左向右翻转模块。

提示

或者,要水平翻转模块,请按 Ctrl+I

要旋转或翻转一组模块,请先选择多个模块,然后旋转或翻转它们。您只能向左或向右翻转模块组。

旋转或翻转一组模块后,可以通过编辑信号线来提高模块图的可读性。自动排列选项可以改进信号的外观。(有关对具有多个端口的情况进行旋转的信息,请参阅标识旋转或翻转模块上的端口位置。)

例如,假设您顺时针旋转这些选定的模块。

The model contains two rows of blocks, each consisting of a Constant block connected to a Subsystem block connected to a Gain block. Both Gain blocks connect to a Scope block. The top row of blocks is selected.

旋转模块后,一些模型元素可能会重叠。

The selected row of blocks has rotated and become a vertical column of blocks. The Constant block is at the top in its original orientation. Below the Constant block is the Subsystem block. The Subsystem block is rotated 90 degrees counterclockwise. Below the Subsystem block is the Gain block. The gain block is rotated 90 degrees clockwise. The signal line from the selected Subsystem block to the selected Gain block crosses over the block icon of the unselected Subsystem block.

在选中模块和信号的状态下,在格式选项卡上,点击自动排列

The block diagram is rearranged such that the signal line from the selected Subsystem block to the selected Gain block no longer crosses over the block icon of the unselected Subsystem block.

标识旋转或翻转模块上的端口位置

旋转可使模块的端口从两侧转到顶部和底部,或从顶部和底部转到两侧,具体取决于端口的位置。旋转之后的模块端口位置取决于模块的端口旋转类型

旋转可能会更改某些模块上的端口位置,以保持从左到右或从上到下的端口编号顺序。旋转之后端口重新排序的模块采用默认端口旋转类型。此原则有助于保持在控制系统建模应用中使用的从左到右、从上到下的模块图方向惯例。下图显示了采用默认端口旋转原则的模块进行顺时针旋转之后的效果。

A Subsystem block has two output ports on the left and two input ports on the right. The top input and output ports are labeled with the number 1 on the block icon, and the bottom input and output ports are labeled with the number 2.

封装模块可以指定端口在旋转后保持其顺序(请参阅图标绘制命令)。这些模块采用物理端口旋转类型。在设计要用于物理系统建模或其他应用的模块时,如果模块图没有首选的方向,则此原则很有用。下图显示了采用物理端口旋转类型的模块进行顺时针旋转之后的效果。

A Subsystem block with a mask has two output ports on the left and two input ports on the right. The top input and output ports are labeled with the number 2 on the block icon, and the bottom input and output ports are labeled with the number 1.

翻转模块可使端口移动到模块的另一侧,生成一个镜像模块,而不管端口的旋转类型是什么。

移动端口

您可以在这些模块的任意一侧按任何顺序放置端口:

您可以通过点击并拖动端口来移动端口。

对于 Subsystem 模块,每次移动后,端口索引将自动重新编号。有关 Subsystem 模块上的端口标签编辑,请参阅Edit Port Labels on Subsystem Blocks

您可以将端口拖到 Subsystem 模块的任何一侧。

您无法拖动封装或链接的 Subsystem 模块上的端口。

The video shows a Subsystem block with three input ports and three output ports. From top to bottom along the left edge of the block, the input ports are labeled 1, 2, and 3. From top to bottom along the right edge of the block, the input ports are labeled 1, 2, and 3. The pointer moves input port 1 between input ports 2 and 3. When the pointer releases the port, the port labels update so that from top to bottom along the left edge of the block, they again read 1, 2, and 3. The pointer drags what is now input port 2 to the top of the block. When the pointer releases the port, the port labels update so that the top port label is 3, and the two ports along the left edge from top to bottom are 1 and 2. The pointer drags input port 2 to the right edge of the block. The port labels do not change.

相关主题