Subsystem, library, or model referencing, when wanting unique block names?

1 view (last 30 days)
Hi MATLAB Community,
I want to create a component, consisting of multiple blocks, that I can re-use multiple times in multiple models. I want this component to be able to take on different parameters for each instance of it that I create (think resistors having different resistances), but for all instances of the component to be changed if I make a fundamental change to its internal composition.
For example, say I have a component consisting of a resistor, a voltage meter, and a scope (I'm using SimPowerSystems). I want to be able to add this component to several models. However, say I change the voltage meter to a current meter -- I want this change to be reflected everywhere; that is, everywhere I've used this component.
And, an additional consideration: every time I add this component to a model, I want the names of internal blocks (say, the scope in my example) to be unique. So, say I add component1 to a model (containing "Scope1")... if then I add another component to the same model, I want its scope to be called "Scope2", without me having to manually change the name.
What do you recommend -- subsystems, libraries, or model referencing? Using the InitFcn callback of the component to automatically change the name?
Thanks so much everyone, I appreciate your help and hopefully my description was reasonably clear.
J.

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 16 Jul 2012
It seems like you have the ideal use-case for creating a masked subsystem block (with the parameters that can be changed registered as mask variables) that is part of a library. Could simply need to mask your subsystem and save it to a library model. Then, in all models that need to use the component, you simply need to drag the subsystem from your library model. Any changes that you need to make must be made to the library so that all linked instances are automatically updated.
Regarding the names of the internal blocks - may I ask why you need this to be done? Since all the internal blocks are inside your subsystem (whose name is automatically unique-ified by Simulink), their path is always unique. For example, if your subsystem is called "mycomponent", and you drag in two instances of it into a model, the second one is automatically renamed to "mycomponent1" by Simulink. So the internal blocks will be "mycomponent/Scope" and "mycomponent1/Scope" - their paths are thus unique.

More Answers (1)

Julian
Julian on 24 Jul 2012
Thank you so much Kaustubha. A masked subsystem block as part of a library worked just as I wanted it to. In fact, I ended up using a system of nested masked subsystem blocks, without problem.
I have not yet solved how to create individual names for my components, although perhaps I don't need to. The motivation for this is that I have outputs (to workspace) in each subsystem, and I want these outputs to have unique names so that I can access them individually.
If you have a suggestion on how to best perform this, I'd be very grateful.
  3 Comments
Julian
Julian on 25 Jul 2012
Hi Kaustubha,
thanks again for your prompt and helpful feedback. I've decided to do away with the To Workspace blocks altogether, and use only signal logging instead. This works fine and avoids name clashes.
Thanks very much,
Julian
Kaustubha Govind
Kaustubha Govind on 25 Jul 2012
Great! Thanks for posting your solution! (Also, could you accept my answer since your issue is resolved?)

Sign in to comment.

Categories

Find more on Composite Components in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!