This example shows how to create a protected model and use it in normal mode simulation, accelerator mode simulation, and code generation.
To create protected models, you must have Simulink® Coder™ installed. To generate the read-only view of protected models, you must have Simulink® Report Generator™ installed.
Open and simulate the example model
The example model contains one Model block named CounterA. To protect the model referenced by this block, select the block and click Protect on the Model Block tab. A dialog box opens where you can select options for creating a protected model.
Under Allow user of protected model to, select Open read-only view of model, Simulate, and Use generated code. To password-protect these actions, you can enter a unique password for each action. Then, click Create.
A project archive for the protected model,
sldemo_mdlref_counter_bus_protected.mlproj, is generated in the specified destination folder.
Double-click the project archive in the Current Folder browser to open the corresponding project that contains the protected model (
sldemo_mdlref_counter_bux.slxp). The project also contains a harness model that provides an isolated environment for the protected model and a data dictionary that defines the variables used by the protected model.
You can use the protected model in normal mode simulation, accelerator mode simulation, and code generation. You can also open a read-only view of the model. The original model file is not required.
When a Model block references a protected model, the block displays a shield badge.
To enable password-protected functionality, right-click the shield badge and select Authorize. Enter the passwords you set while creating the protected model.
After entering the passwords, you can simulate the model in either normal or accelerator mode. You can also generate code for the top model.
To open a read-only view of the protected model, double-click the Model block or right-click the shield badge and select Show Webview.
To open the protected model report, right-click the shield badge and select Display Report.
Simulink.ModelReference.protect (Simulink Coder)