This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Modify Bus Objects

Modify a bus object or its bus element objects if you change the associated bus signal to:

  • Add or delete a bus element signal.

  • Reorder bus element signals.

  • Change the data type or dimensions of a bus element signal.

If you modify a bus object to reflect changes to a bus signal, confirm that the bus object continues to work in other places it is used. To find where a bus object is used in a model, see Finding Blocks That Use a Specific Variable.

If you do not want to change the bus object, you can:

  • Create a bus object that matches the changes to the bus signal and use the new bus object for the blocks that the changed bus connects to.

  • Revert the bus signal changes so that the bus signal continues to match the associated bus object.

You can use the Bus Editor to change and delete existing bus objects and bus elements. The Bus Editor displays all the bus objects in the base workspace. Changes that create, reorder, or delete entities take effect immediately in the base workspace. Changes to properties take effect when you apply them. The Bus Editor does not provide an undo capability.

If you have saved a bus object in a MATLAB® code file, you can edit it programmatically. For details, see Create Simulink.Bus and Simulink.BusElement Objects Directly.

Edit Bus Objects

  1. Open the Bus Editor.

  2. In the Hierarchy pane, expand Base Workspace (if necessary) and select the bus object to edit.

    Tip

    If the base workspace contains many bus objects, you can reduce the number of displayed bus objects by using a Bus Editor filter. For details, see Filter Displayed Bus Objects.

  3. In the Dialog pane, edit the bus object properties.

  4. Click Apply.

Edit Bus Element Objects

  1. Open the Bus Editor.

  2. In the Hierarchy pane, expand Base Workspace (if necessary) and select the bus object whose bus element object you want to modify.

  3. In the Contents pane, select the bus element whose properties you want to edit. You can make the edits in the Dialog pane or in the Contents pane. To make the same edit to a property in multiple bus elements, use the Contents pane. Hold the Ctrl key while you select multiple bus elements and enter the new value in the property for one of the selected bus elements. The change applies to all the selected bus elements.

  4. If you made edits in the Dialog pane, click Apply.

Copy and Paste Bus Objects and Elements

You can use the Bus Editor to copy and paste bus objects or bus element objects. Right-click an object and use the context menu to copy and paste the bus object. Copying a bus object also copies its bus elements. The copied objects have the same property values as the original objects. Change the name of the objects and modify other properties as necessary.

Change the Order of Bus Elements

To change the order of bus elements in a bus object, in the Hierarchy pane, select a bus element and move it up or down in the list, using the Move Element Up

or the Move Element Down button.

Delete Bus Objects and Bus Elements

To delete a bus object, in the Hierarchy pane, select the bus object and click the Delete button or Delete key. Deleting a bus object deletes its bus element 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.

Filter Displayed Bus Objects

By default, the Bus Editor displays all bus objects that exist in the base workspace, in alphabetical order. When there are many bus objects, you can have the Bus Editor 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

To set a filter, specify values in the Filter boxes to the right of the tools in the toolbar. Depending on the specified type of filtering, one or two boxes appear to the right of the Filter Type box. In this example, the Bus Editor displays the bus objects that are in the base workspace:

The bus objects shown form two disjoint hierarchies. A1_Top is the parent of A2_Mid, which is the parent of A3_Bot. Similarly, B1_Top > B2_Mid > B3_Bot.

Filter by Name

Set Filter Type to by Bus Name and in Object Name, enter a character vector. 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 expression that you have typed. The comparison is case-sensitive. For example, entering A displays:

Filter by Relationship

Set Filter Type box to by Bus Object Dependency. In the Relationship box, 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.

In Object Name, specify a bus object by name, using a character vector. Use the list to select any existing bus object name, or type a name. As you type, the editor:

  • Dynamically completes the field to indicate the first bus object that alphabetically matches what you have typed

  • Updates the display panes to show only the specified object and any objects that have the specified relationship to it

For example, assuming that A1_Top is the parent of A2_Mid, which is the parent of A3_Bot, if you enter B2, the Bus Editor displays for Bus Object and Dependents:

Change Filtered Objects

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.

If you create a bus object but do not see it in the editor, check the filter. The new object (whose name always begins with BusObject) can exist but be invisible. Bus objects created or imported from outside the Bus Editor are not visible until you reopen the Bus Editor, regardless of whether a filter is in effect.

Operations performed in the Hierarchy pane on the Base Workspace affect only visible objects. An object that is invisible because a filter is being used is unaffected by the operation. To act on all existing bus objects, clear the filter by clicking Clear Filter.

See Also

Classes

Related Topics