how to protect nested reference models

2 次查看(过去 30 天)
Let's say I have the following structure of 3 reference models:
A is the parent reference model, and inside it references the reference models B and C.
If I want to protect all of them, can I just run: Simulink.ModelReference.protect(A), or should I protect individually all the 3 reference models?
Regards

回答(1 个)

Sachin Lodhi
Sachin Lodhi 2024-3-5
Protecting the top-level model alone might seem adequate, yet it's considered best practice to secure each model in a set, including any parent and child reference models. This is because the Simulink.ModelReference.protect function is designed to operate on a single model at a time, securing its contents and optionally enabling code generation while keeping the model simulatable. Given your scenario with parent reference model A, which references models B and C, you should run Simulink.ModelReference.protect separately for each of the models A, B, and C. Here's how you could do it:
% Protect model A
Simulink.ModelReference.protect('A', 'Webview', true);
% Protect model B
Simulink.ModelReference.protect('B', 'Webview', false);
% Protect model C
Simulink.ModelReference.protect('C', 'Webview', false);
By protecting each model individually, you ensure that each model is secured according to your protection settings. This approach provides flexibility, allowing you to specify different protection options for each model if needed.
Remember, after protecting a model, you should add the protected version (.slxp file) of that model to the reference model block.

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

产品


版本

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by