Main Content

Protected Model Creator

Specify model protection options and protect model

Renamed from Create Protected Model in R2024a

Description

The Protected Model Creator lets you create a protected model (.slxp).

When you protect a model, you can allow the recipient of the protected model to:

  • Simulate a model that includes the protected model in normal, accelerator, rapid accelerator, or external mode.

  • Open a read-only web view of the model, including model contents and block parameters. Creating a read-only web view of the model requires a Simulink® Report Generator™ license.

  • Generate C and C++ code for a model that includes the protected model, if you have a Simulink Coder™ license.

  • Generate HDL code for a model that includes the protected model, if you have an HDL Coder™ license.

  • Generate code for the protected model through the standalone interface, if you have an Embedded Coder® license and specify an ERT-based system target file for the model.

You can optionally password-protect each option. If you choose password protection for one of these options, the software protects the supporting files by using AES-256 encryption. Before you create a protected model, consider how the third party will use the model. For best practices, see Best Practices for Creating Protected Models.

Open the Protected Model Creator

How you open the tool depends on whether you want to protect a referenced model or the top model.

  • To protect a referenced model, select a Model block that references the model you want to protect. In the Simulink Toolstrip, on the Model Block tab, click Protect.

  • To protect the top model, in the Simulink Toolstrip, on the Simulation tab, click the Save button arrow. Then, select Protected Model.

Parameters

expand all

General

Specify whether to share an interactive rendition of a Simulink model that the recipient can view in a web browser with optional password protection. This read-only web view of the model includes the contents and block parameters of the model.

  • on — Share a web view of the model that you protect. For password protection, create and verify a password with a minimum of eight characters.

  • off — Do not share a web view of the model that you protect.

To open a web view of a protected model, perform one of these actions:

  • Simulink Editor: On the Model block, right-click the protected-model badge icon . Then, select Show Web view.

  • Current Folder Browser: Double-click the protected model file (.slxp).

Dependencies

Creating a read-only web view of the model requires a Simulink Report Generator license.

Specify whether the protected model supports simulation. Optionally, add password protection.

  • on — A model that references the protected model can run in normal, accelerator, or rapid accelerator mode. For password protection, create and verify a password with a minimum of eight characters.

  • off — The protected model does not support simulation.

For information about simulation modes in model hierarchies, see Choose Simulation Modes for Model Hierarchies.

Specify whether the protected model supports C and C++ code generation. Optionally, add password protection.

  • on — A model that references the protected model can run in normal, accelerator, rapid accelerator, or external mode and can support C and C++ code generation. For password protection, create and verify a password with a minimum of eight characters.

  • off — The protected model does not support C or C++ code generation.

When you select this parameter, the software automatically selects Simulation.

Dependencies

To generate C and C++ code, you must have a Simulink Coder license.

Specify the interface for the generated code.

  • Model reference — Build a model reference Simulink Coder target. The code is generated from the referenced model as part of a model hierarchy. Code generation uses this command.

    slbuild('model','ModelReferenceCoderTarget')
  • Top model — Build a standalone Simulink Coder binary executable file for the specified model, using the current model configuration settings. This interface also builds model reference coder targets for the referenced models. The code is generated from the top model with the standalone code interface. Code generation uses this command.

    slbuild('model','StandaloneCoderTarget')

The value you specify determines how software-in-the-loop (SIL) and processor-in-the-loop (PIL) simulations deploy the generated code for the protected model.

  • Model reference — The software deploys the generated code as part of a larger application that uses the referenced model.

  • Top model — The software deploys the generated code as a standalone application.

SIL/PIL simulations can verify the protected model code.

To support code generation for a model that references the protected model, specify Model reference.

Regardless of the code interface, you can simulate the protected model in accelerator mode.

Dependencies

To enable this parameter:

  • Select Code generation.

  • Set the System target file configuration parameter to an ERT-based system target file, for example, ert.tlc. This option requires an Embedded Coder license.

Specify the appearance of the generated code.

  • Binaries — Include only compiled binaries and headers for the generated code. The binary files and headers are visible.

  • Obfuscated source code — Include header files found on the include path. The code in the build folder and the headers referenced by the code are visible, but obfuscated.

  • Readable source code — Include header files found on the include path. The code in the build folder, the headers referenced by the code, and the code comments are visible and readable.

This table compares the Content type parameter values to the corresponding Simulink.ModelReference.protect function argument values.

Content type ValueOutputFormat ValueObfuscateCode Value
Binaries'CompiledBinaries'true
Obfuscated source code'AllReferencedHeaders'true
Readable source code'AllReferencedHeaders'false

Tips

To include only the minimal header files required to build the code with the chosen build settings, use the Simulink.ModelReference.protect function with OutputFormat set to 'MinimalCode'.

Dependencies

To enable this parameter, select Code generation.

Specify whether the protected model supports HDL code generation. Optionally, add password protection.

  • on — A model that references the protected model can run in normal, accelerator, or rapid accelerator mode and can support HDL code generation. For password protection, create and verify a password with a minimum of eight characters.

  • off — The recipient cannot generate HDL code for the protected model.

When you select this parameter, you also select Simulation.

Dependencies

To generate HDL code, you must have an HDL Coder license.

Simulation Options

Since R2022a

Select the parameters that you want the recipient to be able to tune during simulation. For information about tunable parameters, see Tune and Experiment with Block Parameter Values.

To compile the model and list the tunable parameters, click Refresh. (since R2023b)

Select the tunable parameters individually, or click Select All.

For code generation, parameters with non-automatic storage classes are tunable. For more information, see Storage Classes for Parameters and Signals Used in Model Blocks.

Save Options

Specify the path of the folder to contain the generated files.

Dependencies

The model being protected must be on the MATLAB® path. For more information, see What Is the MATLAB Search Path?

Since R2020b

Specify whether to package supporting files, including a harness model, with the protected model in a project archive. The type and number of supporting files depends on the model being protected. Examples of supporting files are a MAT file with base workspace definitions and a data dictionary pruned to relevant definitions. The supporting files are not protected.

  • on — Create a project archive (.mlproj) that contains the protected model, its dependencies, and its harness model. The supporting files are not protected. The project archive is a single file that allows for easy sharing. To create the interactive project, open the project archive.

    Before R2024a: Set Contents to Protected model (.slxp) and dependencies in a project.

  • off — Create only the protected model. If the protected model has dependencies, you must share them separately. Similarly, if you create a harness model for the protected model, you must share the harness model separately.

    Before R2024a: Set Contents to Protected model (.slxp) only.

Tips

Before sharing the project, check whether the project contains the required supporting files. If supporting files are missing, simulating or generating code for the related harness model can help identify the missing files. Add the missing dependencies to the project and update the harness model as needed. For more information, see Manage Project Files.

Dependencies

To enable this parameter, select Simulation.

Specify whether to create a harness model for the protected model. The harness model provides an isolated environment for the protected model, which is referenced by a Model block.

  • on — Create a harness model for the protected model.

  • off — Do not create a harness model for the protected model.

When you create a harness model for a protected model that relies on base workspace definitions, Simulink creates a MAT file that contains the required base workspace definitions.

The harness model must have access to supporting files, such as a MAT file with base workspace definitions or a data dictionary.

Dependencies

To clear this parameter, perform one of these actions:

  • Clear Package protected model with dependencies in a project.

  • Clear Simulation.

Since R2020b

Specify the name of the project archive that contains the generated files. The project inside the archive uses the same name.

If you do not specify a custom name, the default name for the project is the protected model name followed by _protected.

Dependencies

To enable this parameter, select Package protected model with dependencies in a project.

Tips

  • To create a protected model programmatically, use the Simulink.ModelReference.protect function.

    • This function provides options that the Protected Model Creator does not support. For example, you can create a modifiable protected model, add callbacks to the protected model, sign the protected model with a digital certificate, and add a postprocessing function for protected model files.

    • When you create a protected model with this function, you must specify whether to generate the protected model report. The function does not generate this report by default.

  • The Protected Model Creator caches your settings for a model during a MATLAB session. If you close and reopen the Protected Model Creator, the cached settings persist. To restore the default settings, click Reset. Passwords and tunable parameter selections are not cached. (since R2023b)

Version History

Introduced in R2012b

expand all