simulink

How to implement a copy of a subsystem but with different values for constants


I am currently developing a model of a flow through a pipe that I have stored in a subsystem and that I want to use several times inside a larger model as it shall have several pipes in it.

I use some constant blocks inside the pipe model that shall be configurable before the simulation. As of now, I implement this by having a constant source block with a variable. The variable is set to a value by a script that is executed upon loading the block. I have an annotation inside the pipe model that allows opening that script and modifying the value of that constant.

Now if I want to have several pipes in my model but with different values of that aforementioned variable, how can I do this?

(To be honest, I don't much like that value setting via that function. I'd much prefer to have a sort of gui for this pipe model like that of the standard simulink blocks but that is another issue...)


Solution

  • I can think of two solutions:

    Solution 1: Adding InPorts for each parameter of your pipe model

    It is quite easy to do, since you just need to add your constant source blocks outside the subsystem, and modify them for each instance. However, it might be inelegant.

    Solution 2: Working on the subsystem mask

    You can find more information here. It should meet your expectations of a sort of gui for this pipe model. But that may require more work to set it up.