Assigning mask parameters to protected models

17 次查看(过去 30 天)
Following the answer to my question on locking libraries, I ran into a problem that I did not see before. The library I have right now (which I am trying to export to protected model blocks) contains blocks which have a mask applied on them. When my client uses one of my library blocks, he should be able to set some tunable parameters that are defined through the mask coding of the block in question. However, if I create the model, export it to a protected model and then import it through a model block in my library (following the answer in my question linked at the beginning of this question), I cannot apply a mask on the model block which now references the .slxp file of the model whose logic I want to implement in the library. This does make sense logically as the protected model is a sort of "compiled" version of the original model and so any variables used in the model will use the values assigned to them during the build process and thus cannot be changed. Below is an example to show what I mean
The above figure shows a simple model I created which uses one constant block with the value assigned to the variable incValue. The usual flow to use this incValue would be to create a subsystem, create a mask and set this variable as one of the parameters. Otherwise I need to have this variable and assigned value in my workspace. If I do not have this variable in my workspace, the model will throw an error when I try to export it to a protected model. So, during the build process, I set the value of this variable to 1 and exported the model.
Next, in a new model I used the model block and referenced the .slxp file I just created. So now the new model looks like this
Now, If I create a mask on this model block and create a parameter for the incValue variable, it has no effect on the output of the model and it will always take the incValue as 1 since this was the value set in the workspace when the original model was exported to protected model.
My question is this: how do I then create a protected model with tunable parameters that can be changed which I can then put in my library such that when my client wants to use the library block, he won't get access to the underlying logic but he can still set certain parameters which I would have otherwise defined in a mask?
So the flow I am looking to create (or if there is a different way to do that) is like this: original model which contains the logic for a specific library block -> convert to protected model -> reference in a model block in my library -> add a mask with the required parameters and the values of these parameters should be usable in the protected

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2023-12-20

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by