In simulink, I want to create a subsystem that will be used in another model multiple times

5 次查看(过去 30 天)
I have a lot of blocks that I want to merge into a subsystem for convinient access from another simulink model. In the new model I want the subsystem to be used miltiple times. Please note, that the subsystem I want to create has 3 resource pools in, so in my attempt creating the new model, the subsystem I created and used multiple times in the model has errors because the resource pools name are used multiple times. In my understanding it is like the subsystems share the resource pools and dont actually have their own independent ones that is why when a resource is required it has multiple pools to be drawn from(because they have the same name in the subsystems) and that is why the errors appear. Any tips?

回答(1 个)

Abhas
Abhas 2025-6-25
Hi @john,
To solve the resource pool name conflicts in multiple subsystem instances, the best and most maintainable approach is to use Referenced Subsystems with Scoped Resource Pools. You can follow the below steps to configure the same:
  • Convert your subsystem into a separate file by selecting the blocks and converting them to a Subsystem Reference block. Refer to the below link for more details: https://www.mathworks.com/help/simulink/ug/convert-subsystem-to-referenced-subsystem.html
  • Use the command "Simulink.SubsystemReference.convertSubsystemToSubsystemReference" to convert the subsystem programmatically.
  • Set each Resource Pool inside the subsystem to Scoped visibility so that each instance has its own independent pool.
  • Use multiple Subsystem Reference blocks in your model by dragging or copying the reference block; each instance shares logic but maintains separate pools.
This avoids name collisions and allows reuse without duplicating code or pooling issues.
I hope this resolves your issue!

类别

Help CenterFile Exchange 中查找有关 Subsystems 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by