文档

Create and Open Models

创建模型

  1. 在Simuli金宝appnk中®start page, choose a template or search the templates.

    Model templates are starting points to apply common modeling approaches. They help you reuse settings and block configurations and share knowledge. Use model and project templates to apply best practices and take advantage of previous modeling solutions.

    单击模板的标题以阅读说明。

    通过在搜索框中输入文本来搜索模板。您可以输入灵活的搜索选项,包括OR,以及,而不是通配符,模糊(〜)等。使用Lucene搜索引擎查询解析器语法。

    To locate templates that are not on the MATLAB search path, click打开。模型模板具有扩展名。sltx

  2. After selecting the template you want, clickCreate Model

    To use a template without reading the description, click the template image. Alternatively, pressCtrl+nto use your default template. To set a default template, seeUse Customized Settings When Creating New Models

    使用模板设置和内容的新模型在Simulink编辑器中打开。金宝app对于下一步,请参阅在Simulink编辑器中构建和编辑模型金宝app

如果内置模板不满足您的需求,请尝试在Examples选项卡,或者您可以创建自己的模板。看从模型创建模板。On theExamples选项卡,输入搜索术语以查找示例标题和感兴趣的描述,或单击网络上打开进一步的示例查看全部旁边是产品名称。

Use Customized Settings When Creating New Models

您可以指定一个模式模板use for all new models.

  1. Create a model with the configuration settings and blocks you want, then export the model to a template. See从模型创建模板

  2. 要在每个新模型中重复使用这些设置,请使用Simulink启动页面或金宝app金宝appsimulink.defaultModeltemplate功能。

    在开始页面中,单击模板的标题以展开描述,然后单击旁边的下箭头Create Model并选择设为默认

设置默认模型模板后,每个新模型都使用该模板,例如,当您按Ctrl+n,当您使用新型号按钮或使用时new_system。在Simuli金宝appnk中Editor, your default template name is at the top of the list when, on theSimulation选项卡,您选择new>MyDefaultTemplateName

The default template shows a tick mark in the start page.

打开模型

打开模型将模型加载到内存中,并将其显示在Simulink编辑器中。金宝app使用这些技术中的任何一种:

  • On the MATLAB选项卡,单击金宝app。在Simuli金宝appnk开始页面中,从列表中选择最新模型或项目,或单击打开

  • 在Simuli金宝appnk中Editor, on theSimulationtab, select打开>Recent Models并选择一个最近的模型。

  • 在MATLAB命令提示符下,在没有文件扩展程序的情况下输入模型的名称,例如vdp。该模型必须在当前文件夹或MATLAB搜索路径中。

  • 在Simuli金宝appnk中Library Browser, click the开放型号或库按钮

  • 打开the model using the Current Folder browser or your operating system file browser.

小费

Set favorites to easily get back to your favorite models and projects in the start page.

在Simuli金宝appnk启动页面最新文件列表中,您可以将文件添加到收藏夹。然后,收藏夹列表将显示在开始页面中的最新文件之上,因此您可以轻松地重新打开自己喜欢的模型和项目。

要编辑或清除开始页面中最新文件的列表,请右键单击一个最近的文件并使用上下文菜单。

笔记

To open a model created in a later version of Simulink software in an earlier version, first export the model to the earlier version. SeeExport a Model to a Previous Simulink Version

打开模型时负载变量

As you build models, you sometimes define variables for a model. For example, suppose that you have a model that contains a Gain block. You can specify the variablek作为增益而不是在块上设置值。当您使用这种方法时,必须定义变量k为了模拟模型。

打开模型时,您可以使用模型回调来加载变量。

  1. In a model that uses the Gain block, set the blockGain价值为k

  2. Define the variable in a MATLAB script. In MATLAB, selectnew>Script。In the script, enter your variable definitions:

    k=27

  3. Save the script asloadvar.m

  4. In the model, open the Property Inspector. On the造型标签,下设计, click物业检查员。With no selection at the top level of a model, you can use the Property Inspector to set model properties. Otherwise, on the造型选项卡,单击模型设置

  5. In theCallbackssection of the model properties, select预载体作为要定义的回调。在窗格中,输入loadvar

  6. 保存模型。

下次您打开模型时PreloadFcn回调将变量加载到MATLAB工作区中。

To learn about callbacks, seeCallbacks for Customized Model Behavior。要定义以编程加载变量的回调,请参见Programmatically Load Variables When Opening a Model

打开模型with Different Character Encoding

如果打开使用使用不同编码的MATLAB会话中编码的特定字符集的MDL文件,则会出现警告。例如,假设您在配置的MATLAB会话中创建一个MDL文件Shift_JISand open it in a session configured forUS_ASCII。警告消息显示当前会话的编码以及用于创建模型的编码。

SLX文件不会警告,因为它们可以存储任何编码中的字符。

如果您遇到损坏字符的任何问题,例如,使用与模型关联的MATLAB文件时,请尝试使用slCharacterEncoding更改当前MATLAB会话的字符编码以匹配模型字符编码的功能。

金宝appSimulink可以检查模型是否包含当前语言环境中不支持的字符。金宝app有关更多详细信息,请参阅Check model for foreign charactersandSave Models with Different Character Encodings

金宝app模型文件类型

您创建的新模型具有.slxextension by default. Models created before R2012b have the extension.mdl。您可以编辑的模型可以具有.slxor.mdlextension, depending on when they were created or whether you converted them. SeeSave Models in the SLX File Format

.slxpand.mdlp扩展表示您无法打开和编辑的受保护模型。看来自第三方的参考保护模型。模型模板具有扩展名。sltx

金宝appSimulink库也使用.slxextension, but you cannot simulate them. To learn more, seeCreate a Custom Library

也可以看看

||||

相关示例

更多关于