Main Content

Simulink.ProtectedModel.getCurrentTarget

Get current protected model target

Description

currentTarget = Simulink.ProtectedModel.getCurrentTarget(protectedModel) returns the target identifier for the target that is currently configured for the protected model. At the start of a MATLAB® session, the default current target is the last target added to the protected model. Otherwise, the current target is the last target that you used. You can change the current target using the Simulink.ProtectedModel.setCurrentTarget function.

When building the model, the software changes the target to match the parent if the currently selected target does not match the target of the parent model.

example

Examples

collapse all

Add a target to a protected model, and then get the currently configured target for the 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')

Get the currently configured target for the protected model.

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

Input Arguments

collapse all

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

Output Arguments

collapse all

Current target for protected model, specified as a character vector.

Version History

Introduced in R2015a