How to parameterize masked subsystems in a for iterator subsystem

Hi all,
I have the following issue: I want to control 10 different signals with 10 different controllers, but the same type of controller. For each controller I have different parameters. The controller is implemented in a model reference. I was thinking to use a for iterator subsystem for each signal to control. The problem is the parameterization of each controller, as the parameters are different in every loop. How can i implement this, without implementing 10 different control blocks ?

1 comentario

Generally, you should implement the block(s) in Simulink in the same way as the 10 controllers would be implemented in real-world applications. Additionally, it is also possible to implement a single Masked Subsystem block in Simulink that functions like a Siemens PLC, outputting 10 different control signals via 10 separate output ports.

Iniciar sesión para comentar.

 Respuesta aceptada

Hi Fabian, rather than using a For Iterator subsystem, you should use a For Each subsystem.
  • The controller parameter should be made an argument of the controller model.
  • Put the controller model into the For Each subsystem in the parent model; it will have to specify the simulation mode as "Accelerator" (a current limitation)
  • you will need to put a mask on the For Each subsystem
  • add a parameter to the mask, which will represent the entire ensemble of parameters for the ensemble of controllers
  • specify that mask parameter as the value of the argument on the controller model block
  • on the dialog of the ForEach block inside the For Each subsystem, specify a partition for the mask parameter so that each iteration of the subsystem - each invocation of controller - uses a slice of the mask parameter that represents the entire ensemble of parameters
For example, consider this bottom model with scalar model argument "K" which is used by the Gain block:
Now suppose this bottom model is placed inside a ForEach subsystem in a parent model and we assign a parameter value "P" to the model argument "K":
As I mentioned, we need to mask the For Each subsystem and add a mask parameter corresponding to "P". Suppose I do this, and the value of the mask parameter is set to "M", in the model workspace of the parent model. "M" has value [1x10] corresponding to the need to run 10 instances of the controller.
We also need to configure the For Each subsystem to partition the mask parameter "P":
When all of this is done, we can simulate the top model and we see the effect of running a collection of controller models on the ensemble of parameters provided via the mask of the For Each subsystem:

6 comentarios

Thank you very much for your answer. This exactly hits the point. However, I have a Matlab function block inside my model reference where the control parameters serve as an input. I do not know how can I define those parameters as an Instance Parameter for the model reference. Could you quickly explain how to do this? Thank you so much in advance!
Hi @Fabian, if you are asking if a MATLAB Function block can access the model argument "K" in the same way that the Gain block in the bottom model does above, the answer is yes, you can reference it from that block's code and register it as data whose category is "Parameter Data" (not "Input Data" as the block's code might appear to suggest):
Thank you @Matthew Englehart. Yes, I have it done like this. But if I do so, the model reference shows no instance parameters. This is where I am stuck right now. Thanks again for your support, I highly appreciate that!
Hi @Fabian, the parameter has to be
1) defined in the model workspace
2) marked as an argument of the model
Then it will appear in the model block dialog as an instance parameter.
this is exactly what I have. I attached the .slx test file. Maybe you can give me some hint where my mistake may occure.
Another question: How do I have to change the system if I want to simulate each signal with only one control parameterization? Meaning, 10 signals producing only ten outputs?
Thank you so much in advance!
Hi @Fabian, you didn't attach the submodel "Subsystem1" but it is the model that needs to have K in the model workspace, registered as an argument, not the top model "test".

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2024b

Preguntada:

el 9 de Jul. de 2025

Comentada:

el 10 de Jul. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by