Create, modify, and manage bus objects
The Sources pane provides available sources, which are the MATLAB® base workspace and open data dictionaries. The objects that you create are stored in the selected source. In the toolstrip, you can create or open a data dictionary. You can also import objects defined by a MAT file, function, or script into the base workspace.
An interactive table displays information about the objects, such as hierarchy and properties. You can select which columns appear in the table by using the Columns list in the toolstrip. Use the table to:
Filter contents — Enter a universal filter or a column-specific filter.
Change values — Double-click a value in the table and enter a new value. Edit the properties of a bus object and its elements at the top level, not where the bus object is specified as a data type.
Reorder elements — Drag the elements to a new position or use the Move Up and Move Down buttons in the toolstrip.
Cut, copy, and paste elements — Use keyboard shortcuts or the corresponding buttons in the toolstrip.
Delete elements — Press the Delete key or click the Delete button in the toolstrip. When you delete a bus object, you also delete the element objects it contains. Update any blocks that specify the deleted object. To find where a bus object is used in a model, see Finding Blocks That Use a Specific Variable.
In the table, you can edit multiple selected objects of the same type at the same time.
The Property Inspector pane lets you focus on one object at a time and edit its properties. When you enter a value that is not supported, a diagnostic message appears in this pane.
The Bus Editor does not support undo or redo actions. Changes that create, reorder, or delete objects take effect immediately in the base workspace.
The Bus Editor can export object definitions to a MAT file
.mat) or function (
.m). It can also create a
MATLAB structure or
Simulink.Parameter object from a
Simulink.Bus object. You can find these actions in the
Share section of the toolstrip.
Open the Bus Editor
Simulink® Toolstrip: On the Modeling tab, in the Design gallery, click Bus Editor.
MATLAB Command Window: Enter
Model Explorer: In a bus object dialog box, click Launch Bus Editor.
Create Bus Objects Using Bus Editor
Suppose you want to define an interface for a model with a
Simulink.Bus object. For this example, the interface receives signals
saw. You want the interface to group
all the signals. Within that group, you want the interface to group the sinusoidal and
You can create the objects in the base workspace or a data dictionary. In the Sources pane, select the location to contain the new objects.
To create a data dictionary, in the Bus Editor toolstrip, click New. In the dialog box, specify a name for the data dictionary. Then, click Save.
To open a data dictionary, in the Bus Editor toolstrip, click Open. In the dialog box, specify the data dictionary that you want to open. Then, click Open.
In the toolstrip, in the Add gallery, click Bus three times to create three
Name the objects
nonsinusoidal. Double-click each object name in the table and enter the new name or use the Property Inspector pane.
Simulink.BusElement objects to the
Select the object named
interface, and add three
BusElementobjects to it. In the toolstrip, click Bus Element three times.
Name the elements
nonsinusoidal_bus. Double-click each object name in the table and enter the new name or use the Property Inspector pane.
Similarly, select the
sinusoidalbus object and add two elements to it named
nonsinusoidalbus object and add two elements to it named
Any element in a bus can be another bus, which can in turn contain subordinate buses, to any depth. To mimic this bus hierarchy, a bus-element object can specify a bus object data type.
Bus objects named
nonsinusoidal in the
Bus object named
For the object named
sinusoidal_bus, set DataType to
For the object named
nonsinusoidal_bus, set DataType to
The object named
interface now matches the desired hierarchy for
the component interface. To specify the object at a component interface, you can specify
it as the data type of In Bus Element, Inport, Out
Bus Element, and Outport blocks.
Save Bus Objects Using Bus Editor
When you create or modify bus objects in the base workspace or a data dictionary, save the objects for future use. If blocks specify these objects, the objects are required for simulation.
The Bus Editor can save bus objects in a MAT file (
MATLAB function (
.m), or data dictionary
To save the objects that are in the base workspace:
In the Sources pane, select the base workspace.
In the toolstrip, click the Export button arrow. Then, select one of the options, which create a MAT file or MATLAB function.
For MATLAB functions, you have the option to save the objects in a compressed cell format or a more readable object format.
In the Export dialog box, specify the file name, then click Save.
Alternatively, cut or copy the objects from the base workspace. Then, paste them in a data dictionary.
To save the objects that are in a data dictionary:
In the Sources pane, select the modified data dictionary.
In the toolstrip, click Save. Alternatively, right-click the data dictionary and select Save changes.
Manage Bus Objects Using Bus Editor
You can use the Bus Editor to manage bus objects from multiple sources.
You can import bus objects from a function, script, or MAT file.
In the toolstrip, click the Import button arrow, then select one of the options.
In the Import into Base Workspace dialog box, select the file that defines the bus objects and click Open.
The import loads the complete contents of the file, not just the bus objects. The table displays the available bus objects in alphabetical order.
You can also open a data dictionary to manage its bus objects.
In the toolstrip, click Open.
In the Open dialog box, select the data dictionary that defines the bus objects and click Open.
Use filters to quickly find bus elements by name or property value. The filter can be a search term or regular expression. For information about regular expressions, see Regular Expressions.
To quickly find elements with a
double data type, type
double in either the Filter contents box or
the Filter by DataType box that appears when you pause on the
DataType column heading and click the button that appears. As you
type, the table updates dynamically to show only the objects whose names or property
values match the filter and their parents. The comparison is not case-sensitive.
Modify Bus Objects Using Bus Editor
You can use the Bus Editor to modify bus objects in the base workspace and data dictionaries.
To edit one or more objects of the same type in the Bus Editor:
Select the objects that you want to update.
To select multiple noncontiguous objects, hold Ctrl and select each element.
To select multiple contiguous objects, hold Shift and select the first and last element.
To select all objects, first select one object. Then, press Ctrl+A.
Double-click the property value that you want to change for all the selected elements that are the same type of object. Then, specify the new value.
When you commit the new value, the change applies to all the selected objects that are the same type of object.
You can also edit one object at a time in the Property Inspector pane.
To edit an element of a nested bus object, right-click the dimmed element and select Go to to bring you to the editable instance of the element.
To reorder elements, select and drag the elements to a new position or use the Move Up and Move Down buttons in the toolstrip.
You can edit contents in the filtered view just like the unfiltered view. Elements that no longer match the filter disappear from the table. Conversely, if some activity outside the Bus Editor changes a filtered object so that it passes the current filter, the object immediately becomes visible.
Operations affect only the available objects. An object that a filter hides is unaffected by the operation. To act on all available objects, clear the filter.
Initialize Buses and Arrays of Buses Using Bus Editor
You can use the Bus Editor to create MATLAB structures for initialization.
Suppose you have a
Simulink.Bus object named
MyData that contains two elements named
temperature— Signal with a data type of
pressure— Nested array of buses with a data type of
Bus: PressureBusand dimensions specified as
Bus object named
PressureBus has two
Bus object named
MyData. Then, in the
toolstrip, click MATLAB Structure.
Specify a name and location for the new MATLAB structure.
The MATLAB structure specifies an initial condition of
0 for each
MyData_MATLABStruct = struct; MyData_MATLABStruct.temperature = int16(0); MyData_MATLABStruct.pressure = struct; MyData_MATLABStruct.pressure(1).s1 = 0; MyData_MATLABStruct.pressure(1).s2 = 0; MyData_MATLABStruct.pressure(2).s1 = 0; MyData_MATLABStruct.pressure(2).s2 = 0; MyData_MATLABStruct.pressure(3).s1 = 0; MyData_MATLABStruct.pressure(3).s2 = 0;
Optionally, change the initial conditions of the structure elements.
Use the MATLAB structure to specify the Initial condition parameter of a block such as a Unit Delay block.
To create a MATLAB structure for a top-level
Bus object that defines an
array of buses, use the
A bus object cannot directly or indirectly reference itself. If you define a circular structure, the Bus Editor keeps the original data type of the element that would have completed the circle.
Display only the columns that are relevant to you in the Bus Editor. For example, if you do not use
Simulink.ConnectionBusobjects, in the Bus Editor toolstrip, click Columns and clear Type.
When you have a model that creates a bus with a Bus Creator block, you can use the
Simulink.Bus.createObjectfunction to create the corresponding objects instead of creating each
Version HistoryIntroduced before R2006a
R2022a: Custom import and export functions are not supported
Starting in R2022a, the Bus Editor loads faster and has an updated interface for creating, modifying, and managing bus objects. However, the Bus Editor no longer supports custom import and export functions.
cm.BusEditorCustomizer.exportCallbackFcn registration functions from
sl_customization function. To eliminate both customizations in one
operation for a customization manager object named
cm, use this