Changing the port dimensions of a "protected model" / Support of variable size signals

2 次查看(过去 30 天)
Hello everyone,
I use the "Protected Models" feature to protect the contents of my model. However, this causes some difficulties. One of them is that the port dimensions of this "Protected Model" are defined when the model is created.
Unfortunately, this is critical in my case, as only 1 part of my model is protected. All inputs are outside the protected subsystem. This is because different configurations are possible. This means that I can have both [1,2,3] and [1,2,3,4,5,6] as inputs. This should change the dimension of the input port from 3 to 6. Is this somehow possible (if the model has already been created?)? Goal - to have only 1 model for all configurations!!!
I have tried to work with global variables, e.g. "InpDim". I have entered these in the "Port dimensions" field in the input block of my protected subsystem. However, if I change my global variable "InpDim" via Matlab Workspace, this does not really help if the model has already been created.
I don't want to work with placeholders (like -1 or 0) because the model is not suitable for that!!!
Do you happen to have any other ideas on how to get around working with placeholders? Of course, the content should be protected :)
Thank you very much!

采纳的回答

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU 2024-1-25
Hello Vladislav,
The limitations you're experiencing with the port dimensions in a protected model are indeed a challenge when dealing with different configurations. Unfortunately, once a model is protected, its port dimensions cannot be directly altered. However, here are some targeted solutions to consider for your situation:
  1. Variable-Size Signal: Adjust your unprotected model parts to work with variable-size signals, ensuring that the protected model's inputs can adapt to different signal dimensions.
  2. Masked Subsystem: Implement a masked subsystem that wraps your protected model. The mask can provide an interface for input size configuration, managing the adaptation of signal dimensions internally.
  3. Multiple Protected Models: If the range of input sizes is known and limited, create different protected models for each specific input size. Use a MATLAB script to select and load the appropriate model based on the current input size.
  4. Wrapper Model: Develop a wrapper model that preprocesses the input signals, either by padding or truncating, to fit the protected model's expected input dimensions.
  5. For infrequent changes in configurations, you may recompile the model with new dimensions and re protect it each time the input size changes.
  6. Design your system to include Simulink Function blocks that are called with variable-size inputs. Ensure the function blocks are set up to handle variable-size signals.
  7. Custom S-Function: Write a custom S-function that handles variable-size inputs and adapts them for the protected model.
These workarounds can help you maintain a single model configuration while addressing the varying input size requirements. You can look at other features of protected model in the documentation: https://www.mathworks.com/help/simulink/slref/protected-models-for-model-reference.html.
  1 个评论
Vladislav Staver
Vladislav Staver 2024-1-29
Thanks for the information! I wish the model would adapt itself, that would be a cool feature.
I have already tested some of the above points. The best option in my opinion is "Variable-Size Signals". But there is a problem that some simulink blocks cannot be used with variable-size signals (Integrator etc.)
Point 2 is also a good one.
But thanks anyway, I will try more.
Best regards,
Vladislav

请先登录,再进行评论。

更多回答(0 个)

类别

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

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by