File Exchange

image thumbnail

Bus Object Bus Creator

version (22.8 KB) by Landon Wagner
Tool to automatically populate a busCreator with BusElements names defined in a Bus Type.


Updated 14 Jan 2021

View Version History

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

When working with bus object types in a design in order to employ strongly "typed" IO the collection of signals into a busCreator associated with a defined bus object type is tedious. After choosing the "Bus:" type in the busCreator "Output data type" the native busCreator does no further favors for you - the user must know or look up how many signals are in the bus type they wish to employ and set "Number of inputs" accordingly. Worse yet, the user must name the individual signals going into the busCreator with the signal names defined in the bus object type.
This tool's job is to do that favor for you. (Note that the tool itself is just a masked busCreator running some callback scripts so the inclusion of this tool does not overtly stick out in a design.) Details can be found in BOBCreadme.txt but essentially the tool's mask provides the user with candidate bus object types (From the workspace.) to choose from and upon selection and application of a bus object type the tool provides a busCreator with the necessary number of inputs and with those inputs populated with NAMED stubbed signal lines. These names match the BusElement names in the chosen bus object type. From these named stubbed lines the underlying busCreator inherits the names for "Signals in the bus." Again, this saves the user with having to know these signal names and fill them out themselves.

A special thank you to Elie couttet for providing a solution to out of date access of base workspace variables.

Cite As

Landon Wagner (2021). Bus Object Bus Creator (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

Landon Wagner

Hi Elie (My apologies to everyone else - I can't send Elie a direct message.)

Great work on your suggestions! I guess things have changed in MATLAB when it comes to accessing base workspace variables. I added your suggestions and it took right off, thank you again!

I am curious if you have more than one bus type in your workspace. I have dozens of them and I found after changing the lines you suggested which allowed me to access the bus objects, I had to do more to actually have the bus types be applied. It appears some mask parameters I was using when I developed this have become RO when they were R/W. I was able to find those that are R/W and it seems to work well for me. If you give this version a shot let me know if you have success. Thank you again!

Landon Wagner

Hi Elie, I do see that! My apologies, I'm going to try to find some time today to fix it up. Thank you for the heads up!

Elie couttet

Hi all,
In case other people have the same struggle I did with this library, I managed to solve my issue by making a few changes in the mask callbacks. The issue seemed to be linked to the mask only accessing the local workspace and not the base workspace, thus not finding the bus definitions.
Also, calling the callback for every change in the bustype variable lead to not being able to select a different type than the one in the bus. Thus the following 3 changes were made to recover the intended behaviour:
1) Copy-paste of the callback code from bustype variable to the mask initialization code
2) In the initialization code, replacement of "wsVars_BOBC = whos;" with "wsVars_BOBC = evalin('base','whos');"
3) In the callback of applyMOCBSelection, replacement of "busParams_BOBC = eval(mocbBusType_BOBC);" by "busParams_BOBC = evalin('base',mocbBusType_BOBC);"

With these little changes the library now works as described in my models (with MATLAB R2020a). Thank you for developing such a useful library!

Elie couttet

I tried to use this library in version R2020a and it does not seem to work: I get "There is currently no bus objects in the workspace - you have no use for this block. Use a normal Bus Creator instead" whereas I have defined busses and they appear in my workspace. Could you help me?
Thank you,

Péricles Serotini

Hi, Landon. Anyway this can be implemented to be compatible with MATLAB 2008a 32-bits? I've tried with no success to export the .slx to a previous version, but it didn't work.


Landon Wagner

Hi Sebastian, thanks for the feedback! I like your suggestion, yes, I'll try to add that enhancement ASAP.

Sebastian Fischer

That's a very interesting feature. Thanks for the contribution! I'm quite surprised that this feature is not a nativ part of Simulink.

Unfortunately, the Bus Object Bus Creator does not work in case the buses are stored in a data dictionary instead of the workspace. Of course one could export the buses from the data dictionary and import them into the workspace. But that's not really ideal. Is there a chance to modify the Bus Object Bus Creator that it can handle also this case?

Best regards

Frank Chen

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!