Main Content


Add code generation support for current target to protected model



Simulink.ProtectedModel.addTarget(model) adds code generation support for the current model target to a protected model of the same name. Each target that the protected model supports is identified by the root of the Code Generation > System Target file (SystemTargetFile) parameter. For example, if the System Target file is ert.tlc, the target identifier is ert.

To add the current target:

  • The model and the protected model of the same name must be on the MATLAB® path.

  • The protected model must have the Modifiable option enabled and have a password for modification.

  • The target must be unique in the protected model.

If you add a target to a protected model that did not previously support code generation, the software switches the protected model Mode to CodeGeneration and ObfuscateCode to true.


collapse all

Add the currently configured model target to the protected model.

Load the model and save a local copy.


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.


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

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

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


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

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

Input Arguments

collapse all

Model name, specified as a string or character vector. It contains the name of a model or the path name of a Model block that references the protected model.

Version History

Introduced in R2015a