Reuse multiple subsystems with the same variable

1 vue (au cours des 30 derniers jours)
Ante
Ante le 20 Août 2024
Réponse apportée : Shubham le 21 Août 2024
Hi
I have a subsystem that in the block uses interpolation function that gets one of the parameters from that subsystem that is written in the workspace (e.g. variable named r). In more details it's the resistance block from simscape and I get it's value from interpolation using interp2 function.
I want to change the sample points used in interpolation lookuptable and the point values come from the same subsystem.
Since the subsystem is copy pasted how to have each copied subsystem behave on its on rather than all of them using global workspace variable without me changing the names manualy.
What is the recommended way to do this? To have a workspace variable of the same name work in the equation in the block but differently for multiple subsystems.

Réponse acceptée

Shubham
Shubham le 21 Août 2024
Hi Ante,
To achieve independent behavior for each copied subsystem, avoiding the use of global workspace variables, you can use a combination of techniques that leverage Simulink's parameterization capabilities. Here's a recommended approach:
1. Use Masked Subsystems
Create a masked subsystem for your block, which allows you to define parameters that are local to each instance of the subsystem. This way, each copy of the subsystem can have its own set of parameters without interfering with others. You can refer to this documentation: https://in.mathworks.com/help/simulink/ug/create-dynamic-masked-subsystems.html
2. Use Model Workspace or Data Dictionary
If you prefer not to use masked subsystems, you can also use a model workspace or a data dictionary to store parameters that are local to each model or subsystem.

Plus de réponses (0)

Catégories

En savoir plus sur Subsystems dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by