Dealing with array of buses in Simulink®

This demo shows a self modifying masked subsystem to split out the correct subbus from the superbus.
778 Downloads
Updated 1 Sep 2016

View License

Here is the situation. Suppose you have a model that can analyze the properties of a meteor to track its trajectory. You want to use it in a larger model which tracks many such meteors at the same time. You now need a block that can accept a superbus called Mainbus (that contains a lot of subbuses called meteorbus) and split out the relevant subbus (metoerbus).
This block should be able to handles any changes in MainBus and meteorbus automatically on model update (no manual intervention).

Solution: Look at the example “ArrayofBus_example.mdl”. I created a masked subsystem “Meteor Selector” which automatically looks at the Bus Objects (MainBus and meteorbus), figures out how many meteors are in the “MainBus” and the structure of the “misbus” and pulls out the correct meteor.

I simply used a Bus Selector which splits out ALL the meteors and then use a Multiport Switch to pass through the correct meteor(based on input frm the mask) to the outport. The tricky part is to get this to work if the number of meteors in MainBus changes. I got this to happen by writing a script that figures out what needs to be done (at the time of model update) and put that in Mask Initialization callback. Essentially you have to set the correct number of ports for the Bus Selector and the Multiport Switch, delete the existing signal lines and add the required lines.

Instructions:

Open the model “ArrayofBus_example.mdl” and follow the instructions in the annotation.

Cite As

Vijay Swaminathan (2024). Dealing with array of buses in Simulink® (https://www.mathworks.com/matlabcentral/fileexchange/24745-dealing-with-array-of-buses-in-simulink), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Author Block Masks in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!

arrayofbuses_example/

arrayofbuses_example/

Version Published Release Notes
1.2.0.1

Updated license

1.2.0.0

Title update

1.1.0.0

Minor changes in description and comments

1.0.0.0