MATLAB: Subsystem, library, or model referencing, when wanting unique block names

callbackscomponentslibrarymodel referencingname changeSimscape Electricalsimulinksubsystems

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.

Best Answer

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.