文档

Simulink.fileGenControl

Specify root folders for files generated by diagram updates and model builds

句法

cfg = 金宝appsimulink.filegencontrol('getConfig')
金宝appsimulink.filegencontrol(动作,名称,值)

Description

例子

CFG= 金宝appsimulink.filegencontrol('getConfig')将句柄返回到一个实例金宝appsimulink.filegenconfig对象,其中包含这些文件生成控制参数的当前值:

  • cachefolder- 指定用于仿真的模型构建工件的根文件夹,包括simulink®缓存文件。金宝app

  • CodeGenfolder- 指定代码生成文件的根文件夹。

  • CodeGenfolderStructure– Controls the folder structure within the code generation folder.

获得或放the parameter values, use the金宝appsimulink.filegenconfigobject.

这些模拟金宝app®偏好确定MATLAB的初始参数值®session:

例子

金宝appsimulink.filegencontrol(行动,,,,姓名,,,,Valueperforms an action that uses the file generation control parameters of the current MATLAB session. Specify additional options with one or morename,valuepair arguments.

Examples

collapse all

要获得当前MATLAB会话的文件生成控制参数值,请使用getConfig

cfg = 金宝appsimulink.filegencontrol('getConfig');mycachefolder = cfg.cachefolder;mycodegenfolder = cfg.codegenfolder;mycodegenfolderstructure = cfg.codegenfolderstructure;

要设置当前MATLAB会话的文件生成控制参数值,请使用放Configaction. First, set values in an instance of the金宝appsimulink.filegenconfigobject. Then, pass the object instance. This example assumes that your system hasaNonDefaultCacheFolderandaNonDefaultCodeGenFolder文件夹。

%获取当前配置cfg = 金宝appsimulink.filegencontrol('getConfig');%将参数更改为非默认位置用于缓存和代码生成文件夹的%cfg.cachefolder = fullfile('C:',,,,'aNonDefaultCacheFolder');cfg.codegenfolder = fullfile('C:',,,,'aNonDefaultCodeGenFolder');cfg.codegenfoldersstructure =“ targetenvilmentsubfolter”; Simulink.fileGenControl('setConfig',,,,'配置',CFG);

您可以为当前MATLAB会话设置文件生成控制参数值,而无需创建一个实例金宝appsimulink.filegenconfigobject. This example assumes that your system hasaNonDefaultCacheFolderandaNonDefaultCodeGenFolder文件夹。

myCacheFolder = fullfile('C:',,,,'aNonDefaultCacheFolder');mycodegenfolder= fullfile('C:',,,,'aNonDefaultCodeGenFolder');金宝appsimulink.filegencontrol('放',,,,'CacheFolder',,,,myCacheFolder,...'CodeGenFolder',mycodegenfolder,...“ CodeGenFolderStructure”,,,,...金宝appsimulink.filegen.codegenfolderstructure.targetenvironmentsubfolder);

如果您不想在单独文件夹中为不同目标环境生成代码,则“ CodeGenFolderStructure”,指定值Simulink.filegen.CodeGenFolderStructure.ModelSpecific

You can reset the file generation control parameters to values from Simulink preferences.

金宝appsimulink.filegencontrol('重置');

To create file generation folders, use theaction with the'createDir'选项。您可以将以前的文件生成文件夹在MATLAB路径上通过“ KeeppreviousPath”选项。

myCacheFolder = fullfile('C:',,,,'aNonDefaultCacheFolder');mycodegenfolder= fullfile('C:',,,,'aNonDefaultCodeGenFolder');金宝appsimulink.filegencontrol('放',,,,...'CacheFolder',,,,myCacheFolder,...'CodeGenFolder',,,,mycodegenfolder,,,,...“ KeeppreviousPath”,真的,...'createDir',真的);

Input Arguments

collapse all

指定使用当前MATLAB会话的文件生成控制参数的操作:

  • '重置'– Reset file generation control parameters to values from Simulink preferences.

  • '放'– Set file generation control parameters for the current MATLAB session by directly passing values.

  • 'setConfig'– Set file generation control parameters for the current MATLAB session by using an instance of a金宝appsimulink.filegenconfigobject.

姓名-Value Pair Arguments

指定可选的逗号分隔对姓名,,,,Valuearguments.姓名是参数名称和Valueis the corresponding value.姓名must appear inside single quotes ('')。You can specify several name and value pair arguments in any order as姓名1,Value1,...,NameN,ValueN

Example:金宝appsimulink.filegencontrol(行动,,,,姓名,,,,Value);

collapse all

Specify the金宝appsimulink.filegenconfig包含要设置的文件生成控制参数的对象实例。

选项放Config

Example:金宝appsimulink.filegencontrol('setConfig', 'config',CFG);

指定模拟缓存文件夹路径值cachefolder范围。

选项

Example:金宝appsimulink.filegencontrol('set','cachefolder',,myCacheFolder);

Specify a code generation folder path value for theCodeGenfolder范围。您可以指定一个绝对路径或相对于构建文件夹的路径。例如:

  • 'C:\Work\mymodelsimcache'and'/mywork/mymodelgencode'specify absolute paths.

  • 'mymodelsimcache'is a path relative to the current working folder (pwd)。The software converts a relative path to a fully qualified path at the time thecachefolderorCodeGenfolder参数已设置。例如,如果pwdis'/mywork',,,,the result is'/mywork/mymodelsimcache'

  • '../test/mymodelgencode'is a path relative topwd。如果pwdis'/mywork',,,,the result is'/test/mymodelgencode'

选项

Example:金宝appsimulink.filegencontrol('set','codegenfolder',,mycodegenfolder);

Specify the layout of subfolders within the generated code folder:

  • Simulink.filegen.CodeGenFolderStructure.ModelSpecific(默认值) - 在模型特定文件夹中将生成的代码放置在子文件夹中。

  • 金宝appsimulink.filegen.codegenfolderstructure.targetenvironmentsubfolder– If models are configured for different target environments, place generated code for each model in a separate subfolder. The name of the subfolder corresponds to the target environment.

选项

Example:金宝appsimulink.filegencontrol('set','cachefolder',,myCacheFolder,,,,...'CodeGenFolder',mycodegenfolder,,,,...“ CodeGenFolderStructure”,,,,...金宝appsimulink.filegen.codegenfolderstructure.targetenvironmentsubfolder);

Specifiy whether to keep the previous values ofcachefolderandCodeGenfolder在MATLAB路径上:

  • true– Keep previous folder path values on MATLAB path.

  • 错误的(默认值) - 从MATLAB路径中删除以前的旧路径值。

选项reset,,,,, 或者放Config

Example:金宝appsimulink.filegencontrol('reset','keeppreviouspath',true);

如果不存在文件夹,则指定是否为文件生成创建文件夹:

  • true– Create folders for file generation.

  • 错误的(default) – Do not create folders for file generation. The call produces an error.

选项or放Config

Example:金宝appsimulink.filegencontrol('放',,,,'CacheFolder',myCacheFolder,,,,'CodeGenFolder',mycodegenfolder,“ keeppreviouspath”,true,'createir',true);

Avoid Naming Conflicts

使用Simulink.fileGenControlto setcachefolderandCodeGenfolderadds the specified folders to your MATLAB search path. This function has the same potential for introducing a naming conflict as usingaddpathto add folders to the search path. For example, a naming conflict occurs if the folder that you specify forcachefolderorCodeGenfoldercontains a model file with the same name as an open model. For more information, seeWhat Is the MATLAB Search Path?(MATLAB) andFiles and Folders that MATLAB Accesses(MATLAB).

To use a nondefault location for the simulation cache folder or code generation folder:

  1. 删除存在于:

    • 当前的工作文件夹,pwd

    • 您打算使用的非默认模拟缓存和代码生成文件夹。

  2. 通过使用模拟缓存和代码生成文件夹的非默认位置Simulink.fileGenControl或Si金宝appmulink首选项。

输出参数

collapse all

Instance of a金宝appsimulink.filegenconfig对象,其中包含文件生成控制参数的当前值。

Introduced in R2010b

Was this topic helpful?