Bus Editor

Create, modify, and manage Simulink.Bus objects


To interactively create a Simulink.Bus object, and the Simulink.BusElement objects that it contains, use the Simulink® Bus Editor.

The Bus objects that you create using the Bus Editor are stored in the MATLAB® base workspace. To simulate a block that uses a Bus object, the Bus object must be in the base workspace or in a data dictionary.

To save Bus object definitions using the Bus Editor, export the Bus objects from the base workspace into a MATLAB code file or MAT-file. If you save a Bus object in a MATLAB code file, you can edit it programmatically. For details, see Create Bus Objects Programmatically.

You can use the Bus Editor to change and delete existing Bus objects and bus elements. The Bus Editor displays all Bus objects in the base workspace. Changes that create, reorder, or delete entities take effect immediately in the base workspace.


The Bus Editor does not provide an undo capability. Changes to properties take effect when you apply them.

For more information on Bus objects, see Specify Bus Properties with Bus Objects.

Open the Bus Editor

  • On the Modeling tab, in the Design gallery, click Bus Editor.

  • At the MATLAB command prompt, enter buseditor.

  • In the Model Explorer, in a Bus object dialog box, click the Launch Bus Editor button.


expand all

This example shows how to create a Bus object that corresponds to the control bus in model ex_bus_object_tutorial. This bus contains two signals as elements.

  1. In the Bus Editor, click the Add Bus button .

    A Bus object with a default name appears in the left pane and its default properties appear in the Simulink.Bus dialog pane.

  2. Specify the name for the Bus object using the Name property. For easy identification, use a name that reflects the bus associated with the bus object. The bus that combines the valve inputs is named control, therefore, name the Bus object CONTROL.


    Click Apply after editing properties or choose to automatically apply changes when you click a different object.

  3. Click the Add/Insert BusElement button .

    A bus element with a default name and default properties is created in the CONTROL Bus object. The bus element appears in the left pane nested under the CONTROL Bus object.

  4. In the Simulink.BusElement dialog pane, set Name to VALVE1, which reflects the name of the corresponding signal in the bus.

  5. To determine the signal properties for BusElement object VALVE1, open the Block Parameters dialog box for the Constant block.

    The properties on the Signal Attributes tab match the default BusElement object properties, so no change is required.

  6. Similarly, create a BusElement object named VALVE2 that corresponds to the valve2 element.

  7. To determine the signal properties for BusElement object VALVE2, open the Block Parameters dialog box for the Constant1 block.

    The Output data type specified by the Constant1 block is int8, which does not match the default BusElement object properties. Set the DataType property of BusElement object VALVE2 to int8.

Any signal in a bus can be another bus, which can in turn contain subordinate buses, to any depth. Describing nested buses using Bus objects requires nesting the Bus object definitions.

Model ex_bus_object_tutorial has two buses, with one bus nested inside the other bus.

This example shows how to nest a Bus object that corresponds to the control bus in a Bus object that corresponds to the main bus.

  1. Create a Bus object named CONTROL that fully specifies the control bus.

  2. Create a Bus object named MAIN that fully specifies the main bus, temporarily using default values for the BusElement object that specifies the nested control bus.

    To identify that this BusElement object corresponds to a nested bus, you can name it VALVES_BUS.

  3. In the Simulink.BusElement dialog pane for VALVES_BUS, set the Data type parameter to Bus: <object name>, where <object name> is the name of the Bus object for the control bus.


    A Bus object cannot directly or indirectly reference itself. If you define a circular structure, the Bus Editor warns you and sets the data type of the element that would have completed the circle to double.

To edit a Bus object or BusElement object:

  1. In the left pane, select the object to edit.

  2. In the Simulink.Bus or Simulink.BusElement dialog pane, edit the object properties.

  3. Click Apply.

When you have a Bus object selected, you can edit its BusElement objects in the middle pane.

To make the same edit to a property in multiple BusElement objects, use the middle pane. Hold the Ctrl key while you select multiple bus element objects and enter the new value in the property for one of the selected bus element objects. The change applies to all the selected BusElement objects.

You can use the Bus Editor to copy and paste Bus objects or BusElement objects. Right-click an object and use the context menu to copy and paste the Bus object. Copying a Bus object also copies its BusElement objects. The copied objects have the same property values as the original objects.

To change the order of bus elements in a Bus object, in the left pane, select a bus element and use the Move Element Up or Move Element Down button .

To delete a Bus object, in the left pane, select the Bus object and click the Delete button or Delete key. Deleting a Bus object deletes its BusElement objects.

If you delete a Bus object, in the Simulink Editor, update any blocks that use that Bus object. To find where a bus object is used in a model, see Finding Blocks That Use a Specific Variable.

When you create Bus objects in the base workspace, before you close MATLAB, save the Bus objects for future use.

You can save Bus objects to one of these locations:

  • Data dictionary

  • MATLAB code file

  • MAT-file

  • Database or other external files

The Bus Editor can save Bus objects in a MAT-file or MATLAB code file. To save Bus objects in other locations, see Save Bus Objects.


To display a reminder to save Bus objects before closing the Bus Editor, select Options > Always Warn Before Closing.

  1. Select which Bus objects you want to export.

    • To export all visible Bus objects in the Bus Editor, select File > Export to File. Bus objects hidden by a filter do not export.

    • To export only selected Bus objects, right-click a Bus object, then select Export to File.

    • To include nested Bus objects used by the selected Bus object, select Export with Dependent Bus Objects to File.

  2. In the Export dialog box, specify the name for the export file.

  3. Set Save as type to MATLAB files (*.m) or MAT-files (*.mat).

  4. Click Save.

  5. For a MATLAB code file, in the additional dialog box that appears, select the export format.

    • Cell — Stores Bus objects in a compressed format.

    • Object — Store Bus objects in the Simulink.Bus object format, which is easier to read and edit.

By default, the Bus Editor displays all Bus objects that exist in the base workspace, in alphabetical order. When you want to reduce the number of Bus objects displayed, you can apply a filter.

The Bus Editor can display only those Bus objects that have:

  • Names that match a given search term or regular expression

  • A specified relationship to a specified Bus object

You can work with any Bus object that is visible in a filtered display exactly as in an unfiltered display. If you change the name or dependency of an object so that it no longer passes the current filter, the object disappears from the display. Conversely, if some activity outside the Bus Editor changes a filtered object so that it passes the current filter, the object immediately becomes visible.


Bus objects created or imported from outside the Bus Editor are not visible until you reopen the Bus Editor.

Operations performed in the left pane for the base workspace affect only visible objects. An object that a filter hides is unaffected by the operation. To act on all existing Bus objects, clear the filter.

In this example, the Bus Editor displays the Bus objects that are in the base workspace.

These Bus objects form two hierarchies. A1_Top is the parent of A2_Mid, which is the parent of A3_Bot. Similarly, B1_Top is the parent of B2_Mid, which is the parent of B3_Bot.

To filter by name, select by Bus Name from the list and type the filter term. See Regular Expressions (MATLAB) for complete information about MATLAB regular expression syntax.

As you type, the Bus Editor updates dynamically to show only the Bus objects whose names match the filter expression. The comparison is case-sensitive. For example, typing A displays only the Bus objects whose names contain an uppercase A.

To filter by relationship, select by Bus Object Dependency from the list. In the second list that appears, select the type of relationship to display.

  • Bus Object and Parents — Show a specified bus object and all superior Bus objects in the hierarchy (default).

  • Bus Object and Dependents — Show a specified Bus object and all subordinate Bus objects in the hierarchy.

  • Bus Object and Related Objects — Show a specified Bus object and all superior and subordinate Bus objects.

Type a Bus object by name or select an existing Bus object name from the list.

For example, if you select Bus Object and Dependents and type B2, the Bus Editor displays only the Bus object hierarchies that contain the B2 Bus object.

You can use the Bus Editor to import the definitions from a MAT-file or MATLAB code file to the base workspace. The import loads the complete contents of the file, not just the Bus objects.

  1. Choose File > Import into Base Workspace.

  2. Use the Open File dialog box to navigate to and import the desired file.

Introduced before R2006a