主要内容

Manage Simulation Targets for Referenced Models

Asimulation target, orSIM target,是一种自动生成的MEX文件,它实现了在加速器模式下执行的引用模型。金宝appSimulink®在模拟过程中根据需要调用仿真目标,以计算引用模型的行为和输出。金宝appSimulink使用相同的仿真目标,用于在加速器模式下执行的参考模型的所有实例。在正常模式下执行的引用模型的实例不使用仿真目标。

为了创建模型参考模拟目标,Simulink生成代码,该代码对在加速器模式下执行的引用模型施加金宝app了一些要求和限制。除这些约束外,在加速器模式下执行引用模型时,通常可以忽略模拟目标。有关这些约束的信息,请参阅Choose Simulation Modes for Model Hierarchies.

默认情况下,simuli金宝appnk生成了一个引用模型的模拟目标,该模型在加速器模式下执行,如果:

  • The simulation target does not exist when you update the diagram of a direct or indirect parent of the referenced model or simulate the model hierarchy.

  • 模拟目标与参考模型中的结构变化过时。

While generating a simulation target, the MATLAB®命令窗口显示状态消息,以便您可以监视模拟目标生成过程。

To programmatically build a model reference simulation target, use theslbuildfunction.

Note

If you have a金宝appSimulink Coder™许可证,请注意不要将引用模型的模拟目标与这些其他类型的目标混淆:

  • Hardware target — A platform for which金宝appSimulinkCodergenerates code

  • System target — A file that tells金宝appSimulinkCoderhow to generate code for particular purpose

  • Rapid Simulation target (RSim) — A system target file supplied with金宝appSimulinkCoder

  • 模型reference target — A library module that contains金宝appSimulinkCoder引用模型的代码

Reduce Time Spent Checking For Changes

You can reduce the time that Simulink spends checking whether simulation targets require rebuilding by setting configuration parameter values as follows:

  • In all referenced models throughout the hierarchy, set theSignal resolution配置参数到仅显式或者没有任何.

  • In the top model of the model hierarchy, set theRebuild配置参数到If any changes in known dependencies detected. Alternatively, you can use this parameter to specify that Simulink always or never rebuilds simulation targets.

These parameters exist in the configuration set of the model; they are not parameters of the模型堵塞。为引用模型的任何实例设置这些参数均在该模型的所有实例中设置它。

Specify Programming Language of Simulation Targets

To specify the programming language for model reference simulation targets, use theLanguage配置参数模拟目标“配置参数”对话框的选项卡。

使用自定义代码进行仿真目标

To use custom code with Stateflow®或者withMATLAB Functionblocks when building a model reference simulation target, use theInclude custom code for referenced models配置参数。

Caution

在加速器模式下,使用自定义代码进行引用的模型可以产生不同的结果,而不是在不使用自定义代码的情况下模拟模型时。如果自定义代码包括对总线或枚举结构的声明,则如果构建结果重复声明这些结构,则模拟目标生成失败。另外,如果自定义代码使用代表总线或枚举的结构,则可以获得意外的仿真结果。

Control Location of Simulation Targets

金宝appSimulink在slprj构建当前文件夹的文件夹。如果是slprjfolder does not exist, Simulink creates it.

Note

金宝appSimulinkCodercode generation also uses theslprj文件夹。子文件夹slprjprovide separate places for simulation code,金宝appSimulinkCoder代码和其他文件。有关详细信息,请参阅管理构建过程文件夹(Simulink Coder).

You can place generated files in a different root folder than the current working folder. This option allows you to:

  • Store generated files separate from the models and other source materials used to generate them.

  • Reuse or share previously built simulation targets without having to set the current working folder to a previous working folder.

  • 与生成生产代码的单独生成的模拟工件。

The仿真缓存文件夹is the root folder in which to place artifacts used for simulation.

To specify a simulation cache folder to use instead of the current folder (pwd), in the金宝appSimulinkPreferences>Generaldialog box, set the仿真缓存文件夹by entering or browsing to a folder path.

This preference provides the initial defaults for MATLAB session parameters.

另外,you can set theCacheFolderMATLAB session parameter using theset_paramfunction.

>> set_param(0,“ cachefolder”, fullfile('C:','Work','MyModelSimCache'))>> get_param(0,“ cachefolder”)
ans = C:\Work\MyModelSimCache

To override or restore the仿真缓存文件夹preference only for the current MATLAB session, use the金宝appsimulink.filegencontrolfunction. The values you set using金宝appsimulink.filegencontrol在当前MATLAB会话结束时到期。

相关话题