Main Content

Simulink.ProtectedModel.removeTarget

Remove support for specified target from protected model

Description

Simulink.ProtectedModel.removeTarget(protectedModel,targetID) removes code generation support for the specified target from a protected model. You must provide the modification password to make this update. Removing a target does not require access to the unprotected model.

Note

You cannot remove the sim target. If you do not want the protected model to support simulation, use the Simulink.ModelReference.modifyProtectedModel function to change the protected model mode to ViewOnly.

example

Examples

collapse all

Remove a supported target from 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);

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')

Remove support for the ert target from the protected model. You are prompted for the modification password.

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

Verify that support for the ert target has been removed from the protected model.

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

Input Arguments

collapse all

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

Identifier for target to be removed, specified as a string or character vector.

Version History

Introduced in R2015a