Main Content

Simulink.ProtectedModel.setCurrentTarget

Configure protected model to use specified target

Description

example

Simulink.ProtectedModel.setCurrentTarget(protectedModel, targetID) configures the protected model to use the target that the target identifier specifies.

Note

If you include the protected model in a model reference hierarchy, the software tries to change the current target to match the target of the parent model. If the software cannot match the target of the parent, it reports an error.

Examples

collapse all

After you get a list of supported targets, set the current target for a protected model.

Load the model and save a local copy.

openExample('sldemo_mdlref_counter');
save_system('sldemo_mdlref_counter','mdlref_counter.slx');

Add a required password for modifying a protected model. If you do not add a password, you are prompted to set a password when you create a modifiable, protected model.

Simulink.ModelReference.ProtectedModel.setPasswordForModify(...
'mdlref_counter','password');

Create a modifiable, protected model with support for code generation.

Simulink.ModelReference.protect('mdlref_counter','Mode',...
'CodeGeneration', 'Modifiable',true, 'Report',true);

Get a list of targets that the protected model supports.

 st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')

Configure the unprotected model to support a new target.

 set_param('mdlref_counter', 'SystemTargetFile', 'ert.tlc'); 
 save_system('mdlref_counter');

Add support to the protected model for the new target. You are prompted for the modification password.

 Simulink.ProtectedModel.addTarget('mdlref_counter');

Verify that support for the new target has been added to the protected model.

 st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')

Configure the protected model to use the new target.

 Simulink.ProtectedModel.setCurrentTarget('mdlref_counter','ert');

Verify that the current target is the new target.

 ct = Simulink.ProtectedModel.getCurrentTarget('mdlref_counter')

Input Arguments

collapse all

Protected model name, specified as a string or character vector.

Identifier for selected target, specified as a string or character vector.

Introduced in R2015a