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.

Find Model Elements in Simulink Models

As you build and modify your model, it helps when you can understand your model structure and locate specific model elements. Simulink® Editor tools simplify these tasks. Use the tool that is appropriate for your model size and complexity.

  • Use the model browser to view and navigate the structure of your model. You can find an element using the model browser by navigating to it through the model hierarchy. This approach works well for a small model whose structure you are familiar with. See Explore the Model Hierarchy Using the Model Browser.

  • Use Edit > Find to locate model elements that match search criteria. You can search in a selected system and optionally include all systems below it. You can also narrow your results based on search criteria. See Search for Model Elements Using Find.

  • Use the Model Explorer to search the model hierarchy using advanced criteria. You can use it to search the model hierarchy and search for variables. The Model Explorer also enables you to search in and apply a change to multiple model elements at once. See Search Using Model Explorer.

  • Use project-wide search to search across all your models and supporting files in one place. You can find matches inside model files, MATLAB® files, and other project files such as PDF and Microsoft® Word files. See Project-Wide Search.

Explore the Model Hierarchy Using the Model Browser

Use the model browser to navigate a model hierarchy using a tree structure. The browser helps you to understand the organization of your model and explore systems within systems.

To display the model browser, in the Simulink Editor, select View > Model Browser > Show Model Browser. You can also use the Hide/Show Model Browser control on the palette to toggle the browser display.

You can use the commands on the View > Model Browser menu to specify whether to include in the browser blocks that are linked to a library and masked subsystems. For information on these types of blocks, see Linked Blocks and Masking Fundamentals.

Search for Model Elements Using Find

You can search in Simulink models using Edit > Find. Use Find and the Finder interface to locate, navigate to, and select any element that matches the search string that you enter. Searching can match the string anywhere in the element, such as in the name and in parameter values. You can customize the search to look only in certain types of elements or when specific parameters are set a certain way.

Default Search Search Options
In the current systemSpecify to search the current system and all systems below it in the model hierarchy.
In all model elements, including all types of Simulink and Stateflow® objectsNarrow your search to include only the elements you are interested in, such as blocks, annotations, or signals.
In parametersSpecify to omit parameter values from the search.
Case-insensitive, partial matchesSearch for an exact match and use regular expressions.
In referenced models but not in linked blocks or masked systemsYou can turn each of these options off and on.

Perform a Basic Search

Search in the current level of the model sldemo_fuelsys for any model element that contains the number 2.

Tip

Open the Property Inspector to see the properties and parameters of the current selection. Select View > Property Inspector.

  1. Open the model sldemo_fuelsys.

  2. Select Edit > Find.

  3. In the search box, enter 2 and press Enter.

    Nine model elements appear highlighted. The first element found, the copyright annotation, has a stronger highlight to show that it is the current match.

  4. To move to the next element, click the search box down arrow. In this example, the current selection highlight moves to a Constant block. The block name does not appear in the model. Look in the Property Inspector to see the block name, Constant2.

  5. Use the up and down arrows to move through the rest of the elements found.

Perform an Advanced Search

You can narrow your search by specifying search criteria. For an example, see Specify Search Criteria and Sort Results.

  1. Select Edit > Find.

  2. Enter the search string. Alternatively, you can add the search string later.

  3. Click View Details.

  4. Click the Configure advanced search settings button .

  5. In the Advanced Search Settings dialog box, for each criterion you want to set, click the Add property and value button. Select the property and enter the value for each criterion.

  6. Set any other advanced search settings, and then click OK.

  7. If you entered a search string, the search executes. Alternatively, you can enter the search string after you specify the criteria, or enter an asterisk (*) to search for any model element that matches the advanced criteria.

    Tip

    You can cancel a search and view partial search results. In the Finder interface, click the Stop Search button.

Search for a Property Value

Using the search box, you can specify a property and value to search for. Enter the search string in the form Property:Value. For example, to search for all Constant value parameters whose value is throttle_sw , type Value:throttle_sw and press Enter. To search for all Constant blocks, enter BlockType:Constant. To search for text that appears in the description of the block, use the form Description:textstring.

  • Search using the programmatic name of the property. To find the programmatic name, in the Property Inspector, hover over the property.

  • Enter the full property name, case insensitive. You cannot use regular expressions or partial matches for the property name.

  • By default, the value search is case insensitive and finds partial matches. Use the advanced search settings to make the search case sensitive, specify verbatim matches, or search using regular expressions.

To search for a string that has a colon and prevent the text before the colon from being treated as a property, use one of these approaches:

  • Escape the colon using a backslash, for example, Earth\: a planet.

  • Use single or double quotes around the expression, for example, 'Earth: a planet' or "Earth: a planet".

Specify Search Criteria and Sort Results

You can specify criteria for your search and sort the results using the Finder interface. In this example, you search for all elements that contain the string fuel. You then use the Finder interface to narrow your results. You can interact with search results while the search runs. However, you can sort the results only after the search is complete.

Tip

Use the model browser with the Finder interface to select the starting point for your search.

  1. Open the model sldemo_fuelsys.

  2. Select Edit > Find. Next to the search box, click View Details.

  3. To expand the scope of the search, in the Finder interface, click the Click to search in current system and below button .

  4. Search for any elements that include the string fuel. In the search box, enter fuel and press Enter.

    The model has many elements with fuel in the name or in a parameter or property value, including blocks, annotations, signals (data), and Stateflow charts.

    Use the Finder interface to make your results more meaningful. For example, you can sort by any of the headings and double-click an item in the list to go to and select the element in the model. Click an item in the list to make it the current match in the model if it is displayed.

  5. When a search returns too many results, use the advanced search settings. Next to the search box, click the Configure advanced search settings button .

  6. Search only for blocks. In the Advanced Search Settings dialog box, under Object Type, clear the Stateflow check box. Expand the Simulink list and clear the Annotations and Signals check boxes.

  7. Narrow the search further to look only in blocks whose description contains the word input. Under Property : Value, from the property list, select BlockDescription. In the value box, enter input, and then click the Add property and value button. Click OK.

  8. Searching returns fewer blocks. You can add more property values to narrow the search further. For example, you can specify the type of blocks to search in. Open the Advanced Search Settings dialog box. Under Property : Value, add another property-value pair. Set the property to BlockType and the value to MultiPortSwitch. Click the Add property and value button and click OK.

    One block appears in the list.

  9. Clear the advanced search criteria. Click the arrow on the Configure advanced search settings button and select Clear advanced settings.

Search Using Model Explorer

Model Explorer helps you to explore and modify your model using advanced techniques. Use the Model Explorer for to search for:

  • Variables in workspaces and data dictionaries

  • Variable usage in a model

  • Instances of a type of block

  • Block parameters and parameter values

You can combine search criteria and iteratively refine the results. Search in Model Explorer for model elements, starting with the node you select in the model hierarchy. You can search the entire model, in a particular system, or in a system and all the systems below it in the hierarchy. For details on the options, see Search Bar Controls.

Using your search results, you can apply changes to multiple elements at once.

To modify algorithmic block parameters such as the Gain parameter of a Gain block, consider using the Model Data Editor. See Configure Data Properties by Using the Model Data Editor.

Search for a Parameter and Refine Results

In this example, you search for model elements that have an Integer rounding mode parameter. You then refine the results to include only n-D Lookup table blocks. You can use the search results to find out more about how these values are set or make batch changes to the model elements found by the search.

  1. Open the model sldemo_fuelsys.

  2. Open Model Explorer. Select View > Model Explorer > Model Explorer.

    By default, the Model Explorer searches the current system and below. You can use the model hierarchy tree in combination with the Show contents button to specify the scope of the search. For example, you can select a node and set the search to current system only to keep the search only at that level. Set the search to current system and below to search the current system and all the subsystems within it.

  3. For this example, leave the search scope set to search the current system and below, starting with the top level of the model. Specify your search criteria. In the search bar, set:

    • Search to by Property Name

    • Property to Rounding

      Rounding is the programmatic name for the Integer rounding mode parameter. For a list of these names, see Block-Specific Parameters.

  4. Click Search. In the Search Results box, 43 results appear. You can go to an item by clicking the link to the path.

  5. Refine the search. In the search bar, click Search Options and select Refine Search.

    The search button label changes to Refine. With this label in effect, additional search criteria act on the previous set of results.

  6. Set Search to by Block Type and set Type to Lookup_n-D. Click Refine.

    The search returns 5 items.

  7. To work further with the values, click Show Details.

  8. The property you are interested in learning more about or acting on is Rounding. First add a column for it in the search results. Select Rounding from the list (you can enter it in the Find Properties box to locate it quickly), and click the Display property as column in view button.

A column for Rounding appears in the search results. For any parameter or property that appears in a column, you can view, sort, and change values for multiple items. For example, to change the Rounding values on all n-D Lookup Table blocks you find by searching, select all the items in the list. In the Rounding column, click one cell and select a new value from the list (for example, Floor).

Tip

To view a summary of the search options that you used, expand the Number of objects found box by clicking the Show Search Details button .

See Also

Related Examples

More About