Clear Filters
Clear Filters

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

2 views (last 30 days)
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!

Accepted Answer

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU on 25 Jan 2024
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 Comment
Vladislav Staver
Vladislav Staver on 29 Jan 2024
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

Sign in to comment.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!