Main Content

Create Protected Models with Multiple Targets

You can create a protected model that supports multiple code generation targets. This example shows how to use command-line functions to create a protected model that supports code generation for GRT and ERT targets.

  1. Load a model and save a local copy. This model is configured for a GRT target.

  2. 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.

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

    'CodeGeneration', 'Modifiable',true, 'Report',true);
  4. Get a list of targets that the protected model supports.

     st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
    st = 
        'grt'    'sim'
  5. Configure the unprotected model to support an ERT target.

     set_param('mdlref_counter', 'SystemTargetFile', 'ert.tlc'); 
  6. Add support to the protected model for the ERT target. You are prompted for the modification password.

  7. Verify that the list of supported targets now includes the ERT target.

     st = Simulink.ProtectedModel.getSupportedTargets('mdlref_counter')
    st = 
        'ert'    'grt'    'sim'

Related Topics