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'

This example shows how to get the active configuration set for model, then change the system target file to the ERT Create Visual C/C++ Solution File for Embedded Coder.

model='rtwdemo_rtwintro';
open_system(model);

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

% Specify target options for MSVC build
targetOptions.MakeCommand = 'make_rtw'; 
targetOptions.Description = ...
     'Create Visual C/C++ Solution File for Embedded Coder'; 
targetOptions.TemplateMakefile = 'RTW.MSVCBuild';

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

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='rtwdemo_rtwintro';
open_system(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 Pair 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 = 'RTW.MSVCBuild';

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

Example: targetOptions.MakeCommand = 'make_rtw';

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

Introduced in R2009b