Main Content

switchTarget

Select target for model configuration set

Description

example

switchTarget(myConfigObj,systemTargetFile,[]) changes the selected system target file for the active configuration set.

example

switchTarget(myConfigObj,systemTargetFile,targetOptions) sets the configuration parameters specified by targetOptions.

Examples

collapse all

This example shows how to get the active configuration set for model, and change the system target file for the configuration set.

% Get configuration set for model
myConfigObj = getActiveConfigSet(model);
% Switch system target file
switchTarget(myConfigObj,'ert.tlc',[]);

This example shows how to get the active configuration set for the current model (gcs), set various targetOptions, then change the system target file selection.

% Get configuration set for current model
myConfigObj=getActiveConfigSet(gcs);

% Specify target options
targetOptions.TLCOptions = '-aVarName=1'; 
targetOptions.MakeCommand = 'make_rtw'; 
targetOptions.Description = 'my target'; 
targetOptions.TemplateMakefile = 'grt_default_tmf';

% Define a system target file
targetSystemFile='grt.tlc';

% Switch system target file
switchTarget(myConfigObj,targetSystemFile,targetOptions);

Use targetOptions to verify values (optional).

% Verify values (optional)
targetOptions
          TLCOptions: '-aVarName=1'
         MakeCommand: 'make_rtw'
         Description: 'my target'
    TemplateMakefile: 'grt_default_tmf'

Use options to select default ERT target file, instead of set_param(model,'SystemTargetFile','ert.tlc').

% use switchTarget to select toolchain build of defaul ERT target
model='CounterModel';
openExample(model);

% Get configuration set for model
myConfigObj = getActiveConfigSet(model);

% Specify target options for toolchain build approach
targetOptions.MakeCommand = ''; 
targetOptions.Description = 'Embedded Coder'; 
targetOptions.TemplateMakefile = '';

% Switch system target file
switchTarget(myConfigObj,'ert.tlc',targetOptions);

Input Arguments

collapse all

A configuration set object of ConfigSet or configuration reference object of Simulink.ConfigSetRef. Call getActiveConfigSet to get the configuration set object.

Example: myConfigObj = getActiveConfigSet(model);

Specify the name of the system target file (such as ert.tlc for Embedded Coder® or grt.tlc for Simulink® Coder™) as the name appears in the System Target File Browser.

Example: systemTargetFile = 'ert.tlc';

Structure with fields that define a code generation target options. You can choose to modify certain configuration parameters by filling in values in a structure field. If you do not want to use options, specify an empty structure ([]).

Name-Value Arguments

Example: targetOptions = [];

Specify the structure field values of the targetOptions. If you choose not to specify options, use an empty structure ([]).

Example: targetOptions.TemplateMakefile = 'myTMF';

Example: targetOptions.TLCOptions = '-aVarName=1';

Example: targetOptions.MakeCommand = 'make_rtw';

Example: targetOptions.Description = 'Create Visual C/C++ Solution File for Embedded Coder';

Version History

Introduced in R2009b