Modify a Simulink model after protected it
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello,
There is something I don't understand about the function Simulink.ModelReference.ProtectedModel.setPasswordForModify.
I protect my model with the following script:
mdlref = 'myModel';
open_system(mdlref);
set_param(bdroot, 'ModelReferenceNumInstancesAllowed', 1);
save_system(mdlref);
Simulink.ModelReference.ProtectedModel.setPasswordForModify(mdlref, 'password');
Simulink.ModelReference.ProtectedModel.setPasswordForSimulation(mdlref, 'password');
[harnessHande, neededVars] = Simulink.ModelReference.protect(mdlref, 'Report', true, 'Modifiable', true, 'Mode', 'Accelerator');
In this way, for me the final user will be able to modify the protected model because the argument Modifiable is set to true during the model protection.
But, after adding my protected model on a top model, I can access on the inside of the model, I am never asking for the password.
Two answers for me today:
- The modification concerns only some properties of the model because a protected model can be modified in any way,
- I miss a step in the model protection.
Can you help me please? Thank you in advance.
Best regards.
댓글 수: 0
답변 (1개)
Rishav
2024년 5월 9일
Hi Mathieu,
I understand that you are trying to access on the inside of the Simulink model, but you are not asked for the password.
When you use the command below, you will be asked to enter a password for any model modifications in future:
[harnessHande, neededVars] = Simulink.ModelReference.protect(mdlref, 'Report', true, 'Modifiable', true, 'Mode', 'Accelerator');
Below is a snapshot of the pop-up for the password entry:
If you are expecting a graphical prompt for the password, Simulink does not provide one by default. Instead, you need to handle the password input programmatically in your script or application logic.
For example, when you use the 'setPasswordForModify' in your script, it sets the password in the machine so that you can modify your model using the 'modifyProtectedModel' function. Otherwise, if you do not use 'setPasswordForModify' in your script, then on using 'modifyProtectedModel' it will ask you for the password with the help of a pop-up.
Please refer to the following documentations on:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!