To open the Search & Replace dialog box:
Open a chart.
In the Modeling tab, select Find > Find & Replace in Chart.
The Search & Replace dialog box contains the following fields:
Enter search pattern text in the Search for text box. You can select the interpretation of the search pattern with the Match case check box and the Match options field (unlabeled and just to the right of the Search in field).
If you select this check box, the search is case sensitive and the Search & Replace tool finds only text matching the search pattern exactly.
Specify the text to replace the text found when you select any of the Replace buttons (Replace, Replace all, Replace all in this object). See Use Replace Buttons.
This option modifies replacement text. For an understanding of this option, see Replacing with Case Preservation.
By default, the Search & Replace tool searches for and replaces text only within the current Stateflow® chart that you are editing in the Stateflow Editor. You can select to search the machine owning the current Stateflow chart or any other loaded machine or chart by accessing this selection box.
This field is unlabeled and just to the right of the Search in field. You can modify the meaning of your search text by entering one of the selectable search options. See Refine Searches.
Under the Search in field are the selection boxes for Object types and Field types. These selections further refine your search and are described below.
The bottom half of the Search & Replace dialog box displays the result of a search. This area is described in A Breakdown of the View Area.
Enter search pattern text in the Search for text box. You can use one of the following settings to further refine the meaning of the text entered.
By selecting the Match case option, you enable case-sensitive searching. In this case, the Search & Replace tool finds only text matching the search pattern exactly.
By clearing the Match case option, you enable
case-insensitive searching. In this case, search pattern characters entered in lower- or
uppercase find matching text with the same sequence of base characters in lower- or uppercase.
For example, the search entry
"AnDrEw" finds the matching text
This option modifies replacement text and not search text. For details, see Replacing with Case Preservation.
Select this option to specify that the search pattern text is a whole word expression used in a Stateflow chart with no specific beginning and end delimiters. In other words, find the specified text in any setting.
Suppose that you have a state with this label and entry action:
throt_fail entry: fail_state[THROT] = 1;
Searching for the text
fail with the Contains word
option finds two occurrences of
Select this option to specify that the search pattern in the Search
for field is a whole word expression used in a Stateflow chart with beginning and end delimiters consisting of a blank space or a
character that is not alphanumeric and not an underscore character
In the previous example of a state named
throt_fail, if Match whole word is selected, searching for
finds no text within that state. However, searching for
find the text
"fail_state" as part of the second line since it is delimited
by a space at the beginning and a left square bracket (
[) at the end.
Set the Match options field to Regular expression to search for text that varies from character to character within defined limits.
A regular expression is text composed of letters, numbers, and special symbols that
defines one or more candidates. Some characters have special meaning when used in a regular
expression, while other characters are interpreted as themselves. Any other character appearing
in a regular expression is ordinary, unless a back slash (
If the Match options field is set to Regular expression in the previous example of a state named
throt_fail, searching for
"fail_" matches the
"fail_" text that is part of the second line, character for character.
Searching with the regular expression
"\w*_" also finds the text
"fail_". This search uses the regular expression shorthand
"\w" that represents any part-of-word character, an asterisk
*) that represents any number of any characters, and an underscore
_) that represents itself.
For a list of regular expression meta characters, see Regular Expressions.
You specify the scope of your search by selecting from the field regions discussed in the topics that follow.
You can select a whole machine or individual chart for searching in the Search in field. By default, the current chart in which you opened the Search & Replace tool is selected.
To select a machine, follow these steps:
Select the down arrow of the Search in field.
A list of the currently loaded machines appears with the current machine expanded to reveal its Stateflow charts.
Select a machine.
To select a Stateflow chart for searching, follow these steps:
Select the down arrow of the Search in field again.
This list contains the previously selected machine expanded to reveal its Stateflow charts.
Select a chart from the expanded machine.
Limit your search by deselecting one or more object types.
You cannot search in state transition tables with this tool.
Limit your search by deselecting one or more field types.
Available field types are as follows.
Names. Machines, charts, data, and events have valid Name fields. States have a Name defined as the top line of their labels. You can search and replace text belonging to the Name field of a state in this sense. However, if the Search & Replace tool finds matching text in a state's Name field, the rest of the label is subject to later searches for the specified text whether or not the label is chosen as a search target.
The Name field of machines and charts is an invalid target for the Search & Replace tool. Use the Simulink® model window to change the names of machines and charts.
Labels. Only states and transitions have labels.
Descriptions. All objects have searchable Description fields.
Document links. All objects have searchable Link fields.
This topic contains the following subtopics:
Click Search to initiate a single-search operation. If an object match is made, its text fields appear in the Viewer pane in the middle of the Search & Replace dialog box. If the object is graphical (state, transition, junction, chart), the matching object appears highlighted in a Portal pane below the Viewer pane.
The view area of the Search & Replace dialog box displays matching text and its
containing object, if viewable. In the previous example, taken from the
sf_pool model, a search for
"friction" finds the Description
field for the state
TotalDynamics. The resulting view area consists of these
Icon. Displays an icon appropriate to the object containing the matching text. These icons are identical to the icons in the Model Explorer that represent Stateflow objects displayed in View Stateflow Objects in the Model Explorer.
Full Path Name of Containing Object. This area displays the full path name for the object that contains the matching text:
(<type>) <machine name>/<subsystem>/<chart name>.[p1]...[pn].<object name> (<id>)
pn denote the object's parent states.
Viewer. This area displays the matching text as a highlighted part of all search-qualified text fields for the owner object. If other occurrences exist in these fields, they too are highlighted, but in lighter shades.
To invoke the properties dialog box for the owner object, double-click anywhere in the Viewer pane.
Portal. This area contains a graphic display of the object that contains the matching text. That object appears highlighted.
To display the highlighted object in the Stateflow Editor, double-click anywhere in the Portal pane.
If you specify an entire machine as your search scope in the Search in field, the Search & Replace tool starts searching at the beginning of the first chart of the model, regardless of the Stateflow chart that appears in the Stateflow Editor when you begin your search. After searching the first chart, the Search & Replace tool continues searching each chart in model order until all charts for the model have been searched.
If you specify a Stateflow chart as your search scope, the Search & Replace tool begins searching at the beginning of the chart. The Search & Replace tool continues searching the chart until all the chart objects have been searched.
The search order when searching an individual chart for matching text is equivalent to a depth-first search of the Model Explorer. Starting at the highest level of the chart, the Model Explorer hierarchy is traversed downward from parent to child until an object with no child is encountered. At this point, the hierarchy is traversed upward through objects already searched until an unsearched sibling is found and the process repeats.
The Search & Replace tool replaces matching text with the exact (case-sensitive) text you entered in the Replace With field unless you selected the Preserve case option.
If you choose the Preserve case option, matching text is replaced based on one of these conditions:
Matching text has only lowercase characters. Matching text is replaced entirely with the
lowercase equivalent of all replacement characters. For example, if the replacement text is
"ANDREW", the matching text
"bill" is replaced by
Matching text has only uppercase characters. Matching text is replaced entirely with the
uppercase equivalent of all replacement characters. For example, if the replacement text is
"Andrew", the matching text
"BILL" is replaced by
Matching text has uppercase characters in the first character position of each word.
Matching text is replaced entirely with the case equivalent of all replacement characters.
For example, if the replacement text is
"andrew johnson", the matching
"Bill Monroe" is replaced by
Matching text has an uppercase character in the first character position of a sentence
with all other sentence characters in lowercase. Matching text is replaced in like manner,
with the first character of the sentence given an uppercase equivalent and all other sentence
characters set to lowercase. For example, if the replacement text is
tall.", the matching text
"Bill is tall." is replaced by
"Andrew is tall.".
If the matching text does not follow any of these patterns, then the text and case replacement match the user input.
You can activate the replace buttons (Replace, Replace all, Replace all in this object) only after a search that finds text.
When you select the Replace button, the current instance of text matching the text in the Search for field is replaced by the text you entered in the Replace with field. The Search & Replace tool then searches for the next occurrence of the Search for text.
When you select the Replace all button, all instances of text matching the Search for field are replaced by the text entered in the Replace with field. Replacement starts at the point of invocation to the end of the current Stateflow chart. If you initially skip through some search matches with the Search button, these matches are also skipped when you select the Replace all button.
When you select the Replace all in this object button, all instances of text matching the Search for field are replaced by text you entered in the Replace with field everywhere in the current Stateflow object regardless of previous searches.
Informational and warning messages appear in the Full Path Name Containing Object field along with a defining icon.
– Informational Messages
The following messages are informational:
A search was attempted without search text specified.
No matches exist in the selected search scope.
No more matches exist in the selected search scope.
The following warnings refer to invalid conditions for searching or replacing:
The object types and field types that you selected are incompatible.
The matching object is not editable by replacement due to one of these problems.
A simulation is running.
Stop the simulation.
You are editing a locked library block.
Unlock the library.
The current object or its parent has been manually locked.
Unlock the object or its parent.
The following warnings appear if the Search & Replace tool must find the object again and its matching text field. If the original matching object is deleted or changed before an ensuing search or replacement, the Search & Replace tool cannot continue.
If you search for text, find it, and then delete the containing object, this warning appears if you continue to search.
If you search for text, find it, and then delete the containing object, this warning appears if you perform a replacement.
If you search for text, find it, and then change the object containing the text, this warning appears if you perform a replacement.
If you search for text, find it, and then change the Search for field, this warning appears if you perform a replacement.