主要内容

库浏览器

查找并向模型添加模块

说明

库浏览器显示系统上 Simulink® 库的树视图。使用库浏览器向模型添加模块和注解。要浏览可添加到模型的项,请展开树中的库。要使用关键字或短语搜索库项,请使用库浏览器顶部的搜索框。要向模型添加项,请将该项拖到模型中,或右键点击该项并选择选项以将其添加到模型。

默认情况下,库浏览器作为面板停靠在 Simulink 窗口中,以便库浏览器窗口停留在模型一侧,不会覆盖模型画布中要添加项的区域。打开多个 Simulink 窗口时,您可以在每个窗口中打开一个库浏览器。

The image shows the Library Browser in docked mode. In docked mode, the Library Browser has a single pane called the libraries pane. Labels are on the libraries pane, the tree that it contains, the search box, and the Library Browser button.

您可以在停靠模式或独立模式下使用库浏览器。

未停靠的库浏览器处于独立模式。

使用独立模式可以:

  • 将相同项添加到多个 Simulink 窗口。

  • 以全屏模式查看库浏览器。

  • 以编程方式打开、关闭、隐藏或定位库浏览器。

  • 浏览库而不打开 Simulink 模型。

要以独立模式打开库浏览器,请在停靠模式下的库浏览器上,点击“启动独立的库浏览器”按钮 Launch standalone library browser button

有关独立模式的信息,请参阅Library Browser in Standalone Mode

Library Browser in docked mode

打开 库浏览器

  • 在 Simulink 工具条的仿真选项卡上,点击库浏览器。库浏览器以停靠模式打开。

  • 在 Simulink 编辑器中,右键点击链接库模块并选择库链接 > 转至库浏览器,以独立模式打开库浏览器。此选项适用于添加到库浏览器的所有库。

注意

  • 如果打开多个 Simulink 窗口,您可以通过点击对应窗口的工具条中的库浏览器在每个窗口中打开一个库浏览器。

  • 要以编程方式打开或关闭库浏览器,请以独立模式打开库浏览器。slLibraryBrowser 函数对停靠模式下的库浏览器不起作用。

示例

全部展开

您可以使用以下键盘快捷方式与停靠模式下的库浏览器交互。

任务快捷方式
在停靠模式下打开库浏览器选择 Simulink 窗口,然后按 Ctrl+Shift+L
查找模块

Ctrl+FF3

打开搜索结果选项卡并移至在当前页之前访问过的页Alt+向左箭头
打开搜索结果选项卡并移至在当前页后访问过的页Alt+向右箭头
将选定模块插入库浏览器停靠到的模型中Ctrl+I
刷新库F5

注意

当您在 Mac 上使用键盘快捷方式时:

  • command (⌘),而不是 Ctrl

  • option 而不是 Alt

要在停靠模式下导航库浏览器,请展开库窗格中树的库层次结构。

您可以同时展开多个库。

展开库时,库内容显示在树中库名称的下方。

库内容可以是模块、注解和子库的任意组合。

要使用关键字或短语搜索库项,请使用库浏览器顶部的搜索框。

  1. 在搜索框中,键入搜索词或从最近搜索词列表中进行选择。

    Library Browser search box

    要搜索注解,请键入注解中的任何文本或其描述。

  2. 要使用正则表达式搜索、区分大小写搜索或全字搜索,请点击搜索子系统、模块和注解按钮并选择要使用的搜索选项。

    Library Browser search options menu

  3. Enter 键开始搜索。搜索结果选项卡按库分组显示搜索结果。

    如果搜索结果超出 100 条,结果会占用模块窗格的多个页。要导航到结果的上一页或下一页,请使用库浏览器窗口左上角的箭头。

    The image shows the top of the Library Browser in docked mode with the keyword "add" in the search box. The Search Results tab is open, and the line of text right below the tab title shows a two arrows, one pointing left and one pointing right, and the text "Page 1 of 4 (304 Blocks found)."

    要查看搜索字符串匹配的位置,请将指针悬停在模块上。

    要返回浏览库树,请点击选项卡。

例如,搜索可自定义的 Knob 模块。

  1. 在库浏览器顶部的搜索框中,输入关键字 knob

  2. Enter搜索结果选项卡打开并显示两个 Knob 模块。

  3. 将指针悬停在这两个模块上,以确定哪个是可自定义的 Knob 模块。当您将指针悬停在可自定义的 Knob 模块上时,会显示以下文本:simulink_hmi_customizable_blocks/Knob

    The Library Browser in docked mode shows the search results for the keyword "knob." The search results are two Knob blocks. The pointer is hovering over the Knob block on the right, and a tooltip is visible with the text "simulink_hmi_customizable_blocks/Knob."

要查看库项的功能描述,请将指针悬停在该项上。

要打开某个项的帮助文档,请右键点击该项图标并选择该项的帮助

要在将库模块添加到模型之前预览其参数,请右键点击模块图标并选择模块参数。模块参数对话框随即打开。

注意

从库浏览器打开“模块参数”对话框时,无法设置任何参数的值。要设置值,请将模块添加到模型,然后在画布中双击该模块。

例如,打开 Circular Gauge 模块的“模块参数”对话框。

  1. 在库浏览器树中,展开 Simulink 库。

  2. Simulink 库中,展开 Dashboard 子库。

  3. Dashboard 子库中,展开 Customizable Blocks 子库。

  4. Customizable Blocks 子库中,右键点击 Circular Gauge 模块图标并选择模块参数。在“模块参数”对话框中,您可以查看可设置的参数。例如,您可以自定义 Circular Gauge 模块刻度上的最大值、最小值和刻度间隔。

    The left image shows the Library Browser in docked mode with the Simulink library expanded, the Dashboard sublibrary expanded, and the Customizable Blocks sublibrary expanded. In the Customizable Blocks sublibrary, the Circular Gauge block has been right-clicked, and the context menu is open. The pointer hovers over the option labeled Block parameters. The right image shows the Block Parameters dialog box that opens for the Circular Gauge when the pointer clicks Block parameters. All of the buttons and text boxes in the Block Parameters dialog box are grayed out, indicating that they cannot be edited.

要将模块和注解从库浏览器添加到打开的模型,请将模块或注解从库浏览器拖到 Simulink 画布。

例如,将可自定义的 Vertical Gauge 模块添加到打开的模型。

  1. 在库浏览器顶部的搜索框中,输入 vertical gauge

  2. Enter搜索结果选项卡会打开并显示 Vertical Gauge 模块。

  3. 点击 Vertical Gauge 模块并将其拖到画布。

    The Library Browser in docked mode shows the search results for the key phrase "vertical gauge." The search results consist of a single block, the Vertical Gauge block. There is a copy of the Vertical Gauge block in the canvas, and an arrow from the Vertical Gauge block icon in the Library Browser to the Vertical Gauge block in the canvas with the caption "Click and Drag the Block to the Canvas."

调整库浏览器大小时,库内容会调整以匹配窗口宽度。

使用布局按钮在单列 One column layout button 或根据浏览器宽度调整列数的响应式布局 Responsive layout button 之间切换查看模块。

The Library Browser is shown twice, in both instances displaying the commonly used blocks in the Simulink Library. In the image on the left, the blocks are arranged in one column, with the icon and name of each block on the same line. In the image on the right, the blocks are arranged in the responsive layout. The blocks are in two columns, with the name of each block underneath its icon.

您也可以通过编程方式自定义库浏览器的外观。

库和库内容首先按排序优先级排序,然后按排序顺序排序。

库按排序优先级升序显示。默认情况下,Simulink 库的排序优先级为 -1,所有其他库的排序优先级为 0。有关排序优先级的详细信息,请参阅Customize Library Browser Appearance

默认情况下,排序顺序为字母顺序。子库首先显示,然后是子系统,然后是模块,最后是注解。

您可以将库项的排序顺序更改为模型顺序,即库开发人员设置的顺序。通常,模型顺序根据功能对内容进行排序,并将相关模块组合在一起。

注意

在停靠模式下,您只能更改库项的排序顺序。对于库和子库,排序顺序始终是字母顺序。

要在停靠模式下从字母顺序切换为模型顺序,请右键点击树中的项图标并选择按库模型顺序排序。此设置会在会话之间保留。

要返回字母顺序,请右键点击树中的项图标并选择按字母顺序排序

有些库不遵循排序顺序。例如,在 Simulink 库中,Quick Insert 库始终显示为最后一项,无论选择何种排序选项都是如此。

例如,按模型顺序对 Commonly Used Blocks 子库的内容进行排序。

  1. 在库浏览器树中,展开 Simulink 库。

  2. Simulink 库中,展开 Commonly Used Blocks 子库。

  3. Commonly Used Blocks 子库中,右键点击任意项的图标,例如 Bus Creator 模块图标,然后选择按库模型顺序排序。库的顺序会更改为模型顺序。在模型顺序中,相关模块组合在一起。例如,当 Commonly Used Blocks 子库处于字母顺序时,In1Out1 模块相距较远,但当子库处于模型顺序时,它们会相邻显示。

    The left image shows the Library Browser in docked mode with the Simulink library expanded and the Commonly Used Blocks sublibrary expanded. The contents of the sublibrary are in alphabetical sorting order, and are formatted as a single column. The Bus Creator block icon has been right-clicked, and the context menu is open. The pointer is hovering over the option labeled Sort in library model order. The right image shows the same Library Browser after clicking Sort in library model order. In the left image (alphabetical sorting order), there are three blocks between the In1 and Out1 blocks, whereas in the right image (model sorting order), the In1 block is right above the Out1 block.

在停靠模式下,库浏览器的默认位置在 Simulink 窗口的左侧。

您可以将库浏览器定位在 Simulink 窗口的左侧、右侧或底部。

要将库浏览器移至不同位置,请点击库浏览器窗口的顶部并将其拖动到 Simulink 窗口的左侧、右侧或底部。在出现的蓝色区域上释放库浏览器。

Simulink model of Van der Pol equation, with the Library Browser hovering over a blue area on the right side of the editor

要在停靠模式下最小化库浏览器,请点击库浏览器窗口右上角的最小化按钮箭头 Minimize button,然后选择最小化

要临时展开处于最小化状态的库浏览器,请在 Simulink 窗口的左边缘点击库浏览器选项卡。库浏览器会展开。如果点击画布,库浏览器会再次最小化。

要还原展开的视图,请点击库浏览器窗口右上角的还原按钮箭头 Restore button,然后选择还原。点击画布时,库浏览器不再最小化。

例如,最小化库浏览器,临时展开库浏览器以将 Constant 模块添加到模型,然后再次最小化库浏览器。

  1. 要最小化库浏览器,点击库浏览器窗口右上角的最小化按钮箭头 Minimize button,然后选择最小化。库浏览器窗口消失。

  2. 要临时展开库浏览器,在 Simulink 窗口的左边缘点击库浏览器选项卡。库浏览器窗口重新显示。

    Simulink window with the Library Browser in docked mode and minimized, and the pointer hovering over the Library Browser tab

  3. 在树中,展开 Simulink 库和 Commonly Used Blocks 子库。

  4. Commonly Used Blocks 子库中,点击并将 Constant 模块拖到画布上。

  5. 要最小化库浏览器,点击画布中的任意位置。

您可以创建自己的库,并可选择使其出现在库浏览器中。

有关详细信息,请参阅创建自定义库

有关如何创建一个自定义模块库和自定义模块子库的示例,请参阅将库添加到库浏览器和快速插入

在以下情况下刷新库浏览器:

  • 修改现有库或以 .slx 文件格式重新保存它们。

  • 移动或删除库文件。

  • 添加库。

  • 更改库浏览器的自定义设置。请参阅Customize Library Browser Appearance

要在添加、删除、重新保存或修改库内容后刷新在库浏览器中显示的库,请右键点击库窗格并选择刷新库浏览器。库浏览器会更新,以反映自上次打开或刷新以来在 MATLAB® 路径中添加或删除的任何库或模块。

要在更改库浏览器自定义设置后刷新在库浏览器中显示的库,请在 MATLAB 命令行窗口中输入此命令:

sl_refresh_customizations

有关添加新库后如何刷新库浏览器的示例,请参阅Customize Library Browser Appearance

限制

以下函数对停靠的库浏览器不起作用:

您无法使用 LibraryBrowser.LBStandalone 对象对停靠的库浏览器执行操作。

要使用这些函数和 LibraryBrowser.LBStandalone 对象,请打开Library Browser in Standalone Mode

版本历史记录

在 R2006a 之前推出

全部展开