Main Content

Test Protected Models

To test a protected model that you created, compare the output of the protected model to the output of the original model. Because you supply the protected model from the original model, both the original and the protected model might exist on the MATLAB® path. In the parent model, if the Model block Model name parameter names the model without providing a suffix, the protected model takes precedence over the unprotected model. To override this default when testing the output, in the Model block Model name parameter, specify the file name with the extension of the unprotected model, .slx.

To compare the unprotected and protected versions of a Model block, use the Simulation Data Inspector. This example uses sldemo_mdlref_basic and the protected model, sldemo_mdlref_counter.slxp, which is created in Protect Models to Conceal Contents.

  1. If it is not already open, open sldemo_mdlref_basic.

    openExample('sldemo_mdlref_basic');

  2. Enable logging for the output signal of the Model block, CounterA. In the Configuration Parameters dialog box, in the Data Import/Export pane, select the Signal logging parameter. Click Apply and OK.

  3. Right-click the output signal. From the context menu, select Properties. In the Signal Properties dialog box, select Log signal data. Click Apply and OK. For more information, see Save Signal Data Using Signal Logging.

  4. Right-click the CounterA block. From the context menu, select Block Parameters (ModelReference). In the Block Parameters dialog box, specify the Model name parameter with the name of the unprotected model and the extension, sldemo_mdlref_counter.slx. Click Apply and OK. Repeat this step for CounterB block and CounterC block.

  5. Simulate the model. When the simulation is complete, click the Data Inspector button to open the Simulation Data Inspector.

  6. In the Simulation Data Inspector, rename the run to indicate that it is for the unprotected model.

  7. In the Simulink® Editor, right-click the CounterA block. From the context menu, select Block Parameters (ModelReference). In the Block Parameters dialog box, specify the Model name parameter with the name of the protected model, sldemo_mdlref_counter.slxp. A badge icon appears on the Model block. Repeat this step for CounterB block and CounterC block.

  8. Simulate the model, which now refers to the protected model. When the simulation is complete, a new run appears in the Simulation Data Inspector.

  9. In the Simulation Data Inspector, rename the new run to indicate that it is for the protected model.

  10. In the Simulation Data Inspector, click the Compare tab. From the Baseline and Compare To lists, select the runs from the unprotected and protected model, respectively. To compare the runs, click Compare Runs. For more information about comparing runs, see Compare Simulation Data.

Related Topics