Main Content

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

管理设计数据

使用模型工作区、符号、数据对象和数据类来指定变量值

您可以使用 MATLAB® 变量来配置和管理模型中的信号和模块参数。有关模型如何使用变量的详细信息,请参阅符号解析。要创建、编辑和管理变量,请参阅创建、编辑和管理工作区变量

您可以将模型变量存储在 MATLAB 基础工作区、模型工作区或数据字典中。要决定在何处存储模型变量,请参阅确定在何处存储 Simulink 模型的变量和对象

要使用变量来控制信号和参数特征,如数据类型和代码生成设置,您可以将数据对象存储在工作区或数据字典中。请参阅数据对象

函数

全部展开

Simulink.findVars分析模型中的变量与模块之间的关系
matlab.io.saveVariablesToScript将工作区变量保存到 MATLAB 脚本中
Simulink.data.evalinGlobalEvaluate MATLAB expression in context of Simulink model
Simulink.data.assigninGlobalModify variable values in context of Simulink model
Simulink.data.existsInGlobalCheck existence of variable in context of Simulink model
Simulink.data.dictionary.create创建新的数据字典并创建 Simulink.data.Dictionary 对象
Simulink.data.dictionary.open打开数据字典进行编辑
Simulink.data.dictionary.getOpenDictionaryPathsReturn file names and paths of open data dictionaries
Simulink.dictionary.archdata.createCreate Simulink data dictionary and Architectural Data object (自 R2023b 起)
Simulink.dictionary.archdata.openCreate Architectural Data object representing architectural data of existing Simulink data dictionary (自 R2023b 起)
Simulink.LibraryDictionary.clearClear library dictionary dependency analysis (自 R2021a 起)
Simulink.LibraryDictionary.refreshUpdate library dictionary dependencies (自 R2021a 起)
Simulink.LibraryDictionary.resetLibraryLinksClear cached information on library dictionary links (自 R2022a 起)
Simulink.data.adapters.catalogList registered file adapters (自 R2022b 起)
Simulink.data.adapters.registerAdapterRegister custom file adapter (自 R2022b 起)
Simulink.data.adapters.unregisterAdapterUnregister custom file adapter (自 R2022b 起)

全部展开

Simulink.ModelWorkspace以编程方式与模型的模型工作区进行交互
Simulink.WorkspaceVarStore information about workspace variables and blocks that use them
Simulink.VariableUsageStore information about the relationship between variables and blocks in models
Simulink.CoderInfo指定为信号、状态或参数数据生成代码所需的信息
Simulink.data.Dictionary配置数据字典
Simulink.data.dictionary.SectionConfigure data dictionary section
Simulink.data.dictionary.EntryConfigure data dictionary entry
Simulink.data.dictionary.EnumTypeDefinitionStore enumerated type definition in data dictionary
Simulink.dictionary.ArchitecturalDataEdit architectural data in a Simulink data dictionary programmatically (自 R2023b 起)
Simulink.dictionary.archdata.DataInterfaceEdit data interface in Simulink data dictionary programmatically (自 R2023b 起)
Simulink.dictionary.archdata.DataElementData element of data interface (自 R2023b 起)
Simulink.dictionary.archdata.PhysicalInterfacePhysical interface (自 R2023b 起)
Simulink.dictionary.archdata.PhysicalElementPhysical element of a physical interface (自 R2023b 起)
Simulink.dictionary.archdata.FunctionElementFunction in client-server interface (自 R2023b 起)
Simulink.dictionary.archdata.FunctionArgumentFunction argument in function element of client-server interface (自 R2023b 起)
Simulink.dictionary.archdata.StructTypeStructure data type (自 R2023b 起)
Simulink.dictionary.archdata.StructElementStruct element of a struct type (自 R2023b 起)
Simulink.data.adapters.BaseMatlabFileAdapterBase class used to define file adapter for reading custom file formats (自 R2022b 起)
Simulink.data.DataSourceWorkspaceContains data for external data source (自 R2022b 起)
Simulink.data.adapters.AdapterDataTesterTest custom external file adapter (自 R2022b 起)

主题

Simulink 模型的数据存储

数据存储在模型工作区中

  • 模型工作区
    将模型使用的变量和对象放置在只有该模型可以访问的工作区中。
  • 更改模型工作区数据
    当您将数据存储在模型工作区中时,可以选择数据源,例如,模型文件或外部 MAT 文件。要在数据源中修改变量,可以使用不同的过程,具体取决于您选择的数据源类型。
  • 在模型工作区中指定数据源
    将模型使用的变量和对象存储在模型文件或单独文件中。(可选)将变量和对象存储为您可修改的代码。

数据存储在字典中

对象和变量中的数据存储

  • 创建、编辑和管理工作区变量
    工作区变量使您能够在模块和模型之间共享信息,例如参数值和数据类型。使用不同工具和方法来创建和操作工作区变量。
  • 使用模型资源管理器编辑和管理工作区变量
    查找模型或模块使用的工作区变量、查找使用某个变量的模块、查找未使用的变量,以及重命名模块在任意位置使用的某个变量。在单独的文件中保存和加载变量。
  • 数据对象
    通过使用外部数据对象,在模块图外部指定参数、信号和状态的属性,包括参数值。
  • 符号解析
    您可以控制模型中的模块如何将符号解析为您在工作区中创建的变量和对象。
  • 定义数据类
    通过创建您自己的数据对象类,自定义您的模型与数据(信号、参数和状态)之间的交互方式。
  • Upgrade Level-1 Data Classes
    Simulink no longer supports level-1 data classes. You must upgrade data classes that you created using the level-1 data class infrastructure, which was removed in a previous release.

外部文件中的数据存储

相关信息