Skip to Main Content Skip to Search
Product Documentation

Simulink.fileGenControl - Specify root folders in which to put files generated by diagram updates and model builds

Syntax

Simulink.fileGenControl(action)
cfg = Simulink.fileGenControl('getConfig')
Simulink.fileGenControl('reset', 'keepPreviousPath', true)
Simulink.fileGenControl('setConfig', 'config', cfg, 'keepPreviousPath', true, 'createDir', true)
Simulink.fileGenControl('set', 'CacheFolder', cacheFolderPath, 'CodeGenFolder', codeGenFolderPath, 'keepPreviousPath', true, 'createDir', true)

Description

Simulink.fileGenControl(action) performs a requested action related to the file generation control parameters CacheFolder and CodeGenFolder for the current MATLAB session. CacheFolder specifies the root folder in which to put model build artifacts used for simulation, and CodeGenFolder specifies the root folder in which to put Simulink Coder code generation files. The initial session defaults for these parameters are provided by the Simulink preferences Simulation cache folder and Code generation folder.

cfg = Simulink.fileGenControl('getConfig') returns a handle to an instance of the Simulink.FileGenConfig object containing the current values of the CacheFolder and CodeGenFolder parameters. You can then use the handle to get or set the CacheFolder and CodeGenFolder fields.

Simulink.fileGenControl('reset', 'keepPreviousPath', true) reinitializes the CacheFolder and CodeGenFolder parameters to the values provided by the Simulink preferences Simulation cache folder and Code generation folder. To keep the previous values of CacheFolder and CodeGenFolder in the MATLAB path, specify 'keepPreviousPath' with the value true.

Simulink.fileGenControl('setConfig', 'config', cfg, 'keepPreviousPath', true, 'createDir', true) sets the file generation control configuration for the current MATLAB session by passing a handle to an instance of the Simulink.FileGenConfig object containing values for the CacheFolder and/or CodeGenFolder parameters. To keep the previous values of CacheFolder and CodeGenFolder in the MATLAB path, specify 'keepPreviousPath' with the value true. To create the specified file generation folders if they do not already exist, specify 'createDir' with the value true.

Simulink.fileGenControl('set', 'CacheFolder', cacheFolderPath, 'CodeGenFolder', codeGenFolderPath, 'keepPreviousPath', true, 'createDir', true) sets the file generation control configuration for the current MATLAB session by directly passing values for the CacheFolder and/or CodeGenFolder parameters. To keep the previous values of CacheFolder and CodeGenFolder in the MATLAB path, specify 'keepPreviousPath' with the value true. To create the specified file generation folders if they do not already exist, specify 'createDir' with the value true.

Input Arguments

action

String specifying one of the following actions:

ActionDescription
getConfigReturns a handle to an instance of the Simulink.FileGenConfig object containing the current values of the CacheFolder and CodeGenFolder parameters.
resetReinitializes the CacheFolder and CodeGenFolder parameters to the values provided by the Simulink preferences Simulation cache folder and Code generation folder.
setSets the CacheFolder and/or CodeGenFolder parameters for the current MATLAB session by directly passing values.
setConfigSets the CacheFolder and/or CodeGenFolder parameters for the current MATLAB session by passing a handle to an instance of the Simulink.FileGenConfig object.

'config', cfg

Specifies a handle cfg to an instance of the Simulink.FileGenConfig object containing values to be set for the CacheFolder and/or CodeGenFolder parameters.

'CacheFolder', cacheFolderPath

Specifies a string value cacheFolderPath representing a folder path to directly set for the CacheFolder parameter.

'CodeGenFolder', codeGenFolderPath

Specifies a string value codeGenFolderPath representing a folder path to directly set for the CodeGenFolder parameter.

    Note   You can specify absolute or relative paths to the build folders. For example:

    • '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 the CacheFolder or CodeGenFolder parameter is set. For example, if pwd is '/mywork', the result is '/mywork/mymodelsimcache'.

    • '../test/mymodelgencode' is a path relative to pwd. If pwd is '/mywork', the result is '/test/mymodelgencode'.

'keepPreviousPath', true

For reset, set, or setConfig, specifies whether to keep the previous values of CacheFolder and CodeGenFolder in the MATLAB path. If 'keepPreviousPath' is omitted or specified as false, the call removes previous folder values from the MATLAB path.

'createDir', true

For set or setConfig, specifies whether to create the specified file generation folders if they do not already exist. If 'createDir' is omitted or specified as false, the call throws an exception if a specified file generation folder does not exist.

Output Arguments

cfg

Handle to an instance of the Simulink.FileGenConfig object containing the current values of the CacheFolder and CodeGenFolder parameters.

Examples

Obtain the current CacheFolder and CodeGenFolder values:

cfg = Simulink.fileGenControl('getConfig');
myCacheFolder = cfg.CacheFolder;
myCodeGenFolder = cfg.CodeGenFolder;
 

Set the CacheFolder and CodeGenFolder parameters for the current MATLAB session by first setting fields in an instance of the Simulink.FileGenConfig object and then passing a handle to the object instance:

% Get the current configuration
cfg = Simulink.fileGenControl('getConfig');
% Change the parameters to C:\cachefolder and current working folder
cfg.CacheFolder = fullfile('C:','cachefolder');
cfg.CodeGenFolder = pwd;
Simulink.fileGenControl('setConfig', 'config', cfg);
 

Directly set the CacheFolder and CodeGenFolder parameters for the current MATLAB session without creating an instance of the Simulink.FileGenConfig object:

myCacheFolder = fullfile('C:','cachefolder');
myCodeGenFolder = pwd;
Simulink.fileGenControl('set', 'CacheFolder', myCacheFolder, ...
   'CodeGenFolder', myCodeGenFolder);
 

Reinitialize the CacheFolder and CodeGenFolder parameters to the values provided by the Simulink preferences Simulation cache folder and Code generation folder:

Simulink.fileGenControl('reset');

Alternatives

Instead of setting the CacheFolder and CodeGenFolder parameters just for the current MATLAB session, you can set the Simulink preferences Simulation cache folder and Code generation folder, which provide the initial MATLAB session defaults. The preferences can be set using the Simulink Preferences dialog box or using the MATLAB command set_param.

See Also

Code generation folder | Simulation cache folder

How To

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS