编程式模型编辑
以编程方式创建模型、在模型中添加和连接模块、设置参数和属性以及执行其他基本建模操作。
了解 Simulink® 中编程式模型管理的基础知识。
函数
打开、保存和关闭
simulink | 打开 Simulink 起始页 |
start_simulink | 启动 Simulink 而不打开任何窗口 |
slLibraryBrowser | 打开、加载并关闭 Simulink 库浏览器,创建并获取库浏览器对象的句柄 |
open_system | 打开模型、库、子系统或模块对话框 |
load_system | 将 Simulink 模型加载到内存中 |
save_system | 保存 Simulink 模型 |
close_system | 关闭 Simulink 模型窗口或模块对话框 |
bdclose | 无条件关闭任何或所有 Simulink 模型窗口 |
learning.simulink.launchOnramp | 打开自定进度的交互式培训 (自 R2019a 起) |
添加和删除
add_block | 向模型中添加模块 |
add_line | 在 Simulink 模型中添加信号线 |
delete_block | 从 Simulink 系统中删除模块 |
delete_line | 从 Simulink 模型中删除信号线 |
add_param | Add parameter to Simulink model |
delete_param | Delete model parameter added with add_param
function |
Simulink.BlockDiagram.deleteContents | Delete graphical contents of model |
Simulink.SubSystem.deleteContents | 删除子系统的内容 |
Simulink.history.clear | Clear the Simulink start page and editor history (自 R2020b 起) |
创建
new_system | 在内存中创建 Simulink 模型或库 |
Simulink.createFromTemplate | Create model or project from template |
Simulink.BlockDiagram.createSubsystem | 创建包含指定模块集的子系统 |
Simulink.Annotation | 创建并指定文本注释、图像注释和区域注释的属性 |
获取和设置
docblock | Get or set editor invoked by Simulink DocBlock block |
gcs | 获取当前系统的路径名称 |
getfullname | 获取标识模块或信号线的路径 |
gcb | 获取当前模块的路径名称 |
gcbh | 获取当前模块的句柄 |
gcbp | 获取当前模块的 Simulink.BlockPath 对象 (自 R2019a 起) |
getSimulinkBlockHandle | 从模块路径中获取模块句柄 |
get_param | 获取参数名称和值 |
set_param | 设置 Simulink 参数值 |
Simulink.defaultModelTemplate | Set or get default model template |
getCurrentAnnotation | Get current annotation object (自 R2019a 起) |
getCallbackAnnotation | Get annotation executing callback |
edittime.getDisplayIssues | Check whether model design warnings and errors is on (自 R2019a 起) |
edittime.setDisplayIssues | Detect model design errors and warnings (自 R2019a 起) |
查找、替换和索引
hilite_system | 突出显示模块、信号线、端口或注释 |
find_system | 查找模型、模块、信号线、端口和注释 |
Simulink.FindOptions | Specify options for finding blocks in models and subsystems |
Simulink.findTemplates | Find model or project templates with specified properties |
Simulink.allBlockDiagrams | Find loaded Simulink models and libraries |
Simulink.findBlocks | 在 Simulink 模型中查找模块 |
Simulink.findBlocksOfType | 在 Simulink 模型中查找指定类型的模块 |
replace_block | 替换 Simulink 模型中的模块 |
modelfinder | Search and open examples, models, and projects (自 R2022a 起) |
modelfinder.setDefaultDatabase | Set default database to index models (自 R2023b 起) |
modelfinder.registerFolder | Index models in Model Finder (自 R2022a 起) |
modelfinder.unregisterFolder | Remove models from Model Finder (自 R2022a 起) |
modelfinder.createDatabase | Create new database to index models (自 R2023b 起) |
modelfinder.registerDatabase | Register database with Model Finder (自 R2023b 起) |
modelfinder.unregisterDatabase | Remove database from Model Finder (自 R2023b 起) |
modelfinder.setSearchDatabase | Set search scope to find models (自 R2023b 起) |
选中
isSimulinkStarted | Check whether Simulink is started (自 R2020b 起) |
bdroot | 当前系统的顶层模型 |
bdIsLoaded | Determine whether model, subsystem, or library is loaded |
bdIsLibrary | Determine whether model is library |
bdIsDirty | Determine whether model, subsystem, or library has unsaved changes |
slIsFileChangedOnDisk | Determine whether model has changed since it was loaded |
提取和导出
Simulink.SubSystem.copyContentsToBlockDiagram | 将图形内容从子系统复制到另一个模型 |
Simulink.exportToTemplate | Create template from model or project |
Simulink.exportToVersion | 导出模型、库或工程,用于 Simulink 的以前版本 |
Simulink.MDLInfo | 在不加载文件的情况下提取 SLX、SLXP 或 MDL 文件信息 |
Simulink.MDLInfo.getDescription | Extract SLX, SLXP, or MDL file description without loading file |
Simulink.MDLInfo.getMetadata | Extract SLX, SLXP, or MDL file metadata without loading file |
编辑
Simulink.BlockDiagram.expandSubsystem | Replace subsystem with subsystem contents |
Simulink.BlockDiagram.arrangeSystem | Improve layout of block diagram |
Simulink.BlockDiagram.routeLine | Route existing lines of model (自 R2019a 起) |
slCharacterEncoding | 指定要在从 Simulink 模型生成的代码中使用的编码 |
frameedit | Open PrintFrame Editor to edit print frames for Simulink and Stateflow block diagrams |
主题
- 编程建模基础知识
以编程方式创建模型、在模型中添加和连接模块、设置参数和属性以及执行其他基本建模操作。
- 以编程方式运行仿真
通过编写脚本或在 MATLAB® 命令行窗口中发出命令,以编程方式运行仿真。
- 从 MATLAB 命令行窗口以编程方式打印模型
MATLAB
print
命令提供几个选项用于打印 Simulink 模型。
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)