MATLAB: Simulink: Is there an easy way to replicate a sub-system in the same simulation

replicationsimulinksubsystem

I have a simulation composed of several interconnected subsystems, and I wish extend this to simultaneously, but independently, simulate the same process, but in the reverse direction.
I know that I can copy & paste my existing blocks, then manually rename the variables, gotos, etc.
Wondering if there is a simple and easy way to do this where these are renamed automatically (maybe adding pre-/suffix to the existing names)?
I've tried to keep this general, as I think any answer would apply whatever you might be doing with simulink, but am happy to provide any and all details, if it will help someone find an easier solution.

Best Answer

You can automate this using a script. Some relevant functions include:
  • add_block to add and copy blocks, as well as position them
  • add_line to connect blocks together
  • set_param to rename blocks or change block parameters e.g. Goto/From tag names
- Sebastian