1
votes

In Simulink, I need to perform the same (non-trivial) operation on multiple buses. I thought about implementing that operation as a subsystem and reuse it, but that didn't work out well.

I wonder now if it is possible to iterate the signals/buses within a bus to apply the same operation multiple times and then bundle the results together again. How would I do that?

2
Could you be a little more precise on the problems you had with subsystems? Is that relative to the different names of signals among the busses?Clement J.
I need the subystems to be separate models. When they are in accelerator mode they won't compile, but when I switch them to normal mode I can only use one instance.sunside

2 Answers

1
votes

What release are you using? If you are using R2010b or later, you can use an array of buses and a for-each subsystem. See the documentation for more details on how this works. This will only work if the the multiple buses that you want to iterate have exactly the same structure.

0
votes

I don't have Matlab to test this solution now. I assume your busses are all of the same dimension and structure.

  • Create a block in a library
  • Define a type (bus object) with the bus editor (corresponding to the common structure of your busses)
  • Set the inport and the outport to this type.
  • Use the bus selector to decompose your data, perform your operations and reassemble your busses with a bus creator. The names in the selector/creator are those of the type you defined.
  • Use this block on each signal.
  • Don't forget to export the type to a .mat file and to load it.