Filter Displayed Bus Objects

By default, the Bus Editor displays all bus objects that exist in the base workspace, always in alphabetical order. When a model contains large numbers of bus objects, seeing them all at the same time can be inconvenient. To facilitate working efficiently with large collections of bus objects, you can set the Bus Editor to display only bus objects that:

  • Have names that match a given string or regular expression

  • Have a specified relationship to a bus object specified by name

To set a filter, you specify values in the Filter boxes to the right of the tools in the toolbar. The left Filter box specifies the type of filtering. This box always appears, and is called the Filter Type box. Depending on the specified type of filtering, one or two boxes appear to the right of the Filter Type box. The next figure includes the Filter boxes (near the top of the dialog box) and shows that six bus objects exist 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. See Nest Buses for information about bus object hierarchies.

Filter by Name

To filter bus objects by name, set the Filter Type box to by Bus Name (which is the default). The right Filter box is the Object Name box. Type any MATLAB® regular expression (which can just be a string) into the Object Name box. As you type, the Bus Editor updates dynamically to show only bus objects whose names match the expression you have typed. The comparison is case-sensitive. For example, entering A displays:

Note that FILTERED VIEW appears in three locations, as shown in the preceding figure. This indicator appears whenever any filter is in effect. Entering the additional character 3 into the Object Name box displays:

In a MATLAB regular expression, the metacharacter dot (.) matches any character, so entering .2 displays:

See Regular Expressions for complete information about MATLAB regular expression syntax.

Filter by Relationship

To filter bus objects by relationship, set the Filter Type box to by Bus Object Dependency. A third Filter box, called the Relationship box, appears between the Filter Type box and the Object Name box. You may have to widen the Bus Editor to see all three boxes:

In the Relationship box, select the type of relationship to display. The options are:

  • 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 the Object Name box, specify a bus object by name. You can use the list to select any existing bus object name, or you can 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 that object and any objects that have the specified relationship to it.

When filtering by relationship, you must enter a string, not a regular expression, in the Object Name box. The match is case-sensitive. For example, assuming that A1_Top is the parent of A2_Mid, which is the parent of A3_Bot (as previously described) if you enter B2 (or any leftmost substring that matches only B2_Mid) in the Object Name box, the Bus Editor displays the following for each of the three choices of relationship type:

Bus Object and Parents

Bus Object and Dependents

Bus Object and Related Objects

Note that FILTERED VIEW appears in each the preceding figures, as it does when any filter is in effect.

Change Filtered Objects

You can work with any bus object that is visible in a filtered display exactly as you could 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 vanishes 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.

A new bus object created within the Bus Editor with a filter in effect may or may not appear, depending on the filter. If you create a new bus object but do not see it in the editor, check the filter. The new object (whose name always begins with BusObject) may exist but be invisible. Bus objects created or imported using capabilities outside the Bus Editor are not visible until the Bus Editor window is next selected, regardless of whether a filter is in effect.

Operations performed on the root node Base Workspace in the Hierarchy pane, such as exporting bus objects, affect only visible objects. An object that is invisible because a filter is in effect is unaffected by the operation. If you want to export all existing bus objects, be sure to clear any filter that may be in effect before performing the export.

Clear the Filter

To clear any filter currently in effect, click the Clear Filter button at the right of the Filter subpane, or press the F5 key. The subpane reverts to its default state, in which all bus objects appear:

If you jump from a nested bus object to its source object by selecting the nested object and choosing Go to 'element' from its Context menu, and the source object is invisible due to a filter, the Bus Editor automatically clears the filter and selects the source object. Jumping to an object that is already visible leaves the filter unchanged.

Related Examples

More About

Was this topic helpful?