Subsystem, library, or model referencing, when wanting unique block names?
Mostrar comentarios más antiguos
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.
Respuesta aceptada
Más respuestas (1)
Julian
el 24 de Jul. de 2012
0 votos
3 comentarios
Kaustubha Govind
el 24 de Jul. de 2012
Julian: Is there a reason that you'd like to use To Workspace blocks inside your library blocks? IMO, it is best to simply place outports, so that the user of your blocks can connect the To Workspace blocks to the outputs if needed. I suspect that you will see naming clashes if multiple copies of your block exist in a model. Furthermore, there is a possibility that a user of your block has a variable in the workspace whose name matches what you set in your block, so your To Workspace block will overwrite that variable.
If you absolutely need to use a To Workspace block inside your library block, I will recommend that you make it a mask variable, so that users can name the variable appropriately.
Julian
el 25 de Jul. de 2012
Kaustubha Govind
el 25 de Jul. de 2012
Great! Thanks for posting your solution! (Also, could you accept my answer since your issue is resolved?)
Categorías
Más información sobre Composite Components en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!