| Simulink® Verification and Validation™ | ![]() |
| On this page… |
|---|
Adding Requirement Links to an Object Viewing Requirements Documents |
You can add requirements to the following types of objects:
Simulink model
Simulink block
Stateflow chart, state, transition, box, or function
Note You can add requirements to top-level reference blocks but not to their contents. For example, if you copy a subsystem consisting of multiple blocks from a library, you can add requirements to the subsystem block in your model, but not to its component blocks. |
The Requirements Management Interface supports the following built-in types of requirements documents:
Text
HTML
Microsoft Word
Microsoft Excel
You can also link to an item in the Telelogic DOORS software (see Linking Objects to DOORS Requirements), or register your own custom type of documents to link to (see Linking to Custom Types of Requirements Documents).
Depending on the document type, you can link to specific locations within a document.
| Document Type | Location Options |
|---|---|
| Text |
|
| HTML | You can link only to a named anchor. For example, if you define the anchor <A NAME=valve_timing> ...contents... </A> in your HTML requirements document, you can enter valve_timing in the Location text field or click the Document Index tab to select valve_timing from an automatically generated list of anchors in the document. |
| Microsoft Word |
|
| Microsoft Excel |
|
| |
| Web Browser URL | You can link to a URL location only. Type the URL location string in the Document text field. When you follow the link, the document opens in a Web browser. |
You use the Requirements dialog box to associate a requirements document with a requirements object. You can link a particular location in an existing Microsoft Word or HTML document to a block in a Simulink diagram or a Stateflow object in a Stateflow chart. In this procedure, you add three requirement links to a Simulink block in the demo model sf_car. In later topics, you modify both the links and the documents they point to.
Create and save the Microsoft Word document requirements.doc with the following format. Style the header lines (Primary Requirements, Second Requirements, Tertiary Requirements) as Heading 1 in Microsoft Word.

Type sf_car at the MATLAB prompt to open the demo model sf_car.
Right-click the Engine block and, from the pop-up menu, select Requirements > Edit/Add Links.
The Requirements dialog box for the Engine block appears.

In the Requirements dialog box, click New to add a new requirement.
Fields and tools of the Requirements dialog box are now enabled for the new requirement.
Click Browse next to the Document type field, browse to the requirements document requirements.doc, and select Open.
The Document type field is now set to Microsoft Word. If you specify the document type in the Document type field prior to browsing for the requirements document, only the files of the appropriate type appear. If you set Document type to Unspecified Type, all files are listed.
To define a particular location in the document, click the Document Index tab to create an index of the requirements document.

Select Primary Requirements from the automatically generated list of headings and bookmarks in the document.

If your document does not contain headings or bookmarks, click the Requirements tab.
Select Search text from the Location drop-down list and enter Primary Requirements in the text field. The search text feature is not case-sensitive; primary requirements and PRIMARY REQUIREMENTS work the same in this example.

To provide additional details about the current requirement, enter text in the User tag field. Entering text in the User tag field is optional.
Click Apply.
Select Requirement 1 and click Copy to create a copy of Requirement 1 as a new requirement.
In the Description field, replace Copy of Requirement 1 with Requirement 2, and link Requirement 2 to the text "Secondary Requirements" in requirements.doc.
In addition to the Copy tool, you can edit existing requirements using the following tools.
Tool Button | Description |
|---|---|
Delete | Deletes the requirement. |
Up | Moves the selected requirement up one line in the list of requirements. |
Down | Moves the selected requirement down one line in the list of requirements. |
The Requirements dialog box makes it easier for you to enter a previous document name by remembering up to five of the most recent documents entered. The list of five is taken for all entries made across all models. For example, if you add a new requirement after entering two requirements for the Engine block, and click the drop-down arrow in the Document field for the new requirement, a selectable list of previous requirements documents like the following example would appear.

Click Apply to apply the requirement links you have added and click OK to close the Requirements dialog box.
Save the model as my_sf_car.mdl.
You use this model in Viewing Requirements Documents.
You can access a requirements document through its associated model element. In this section, you access the requirements document using one of the Engine block requirements links:
In the my_sf_car model, right-click the Engine block and select Requirements from the context menu.
The requirements you added now appear as submenu selections.

Select Requirement 2 from the submenu.
requirements.doc opens in its editor, the Microsoft Word software, and the first occurrence of Secondary Requirements is highlighted.

If string text is not specified or does not exist in the requirements document, the requirements document opens with the cursor at the beginning of the file.
Keep requirements.doc and the my_sf_car model open; you will use them in Adding Requirement Links to Multiple Objects Simultaneously.
Browsing for a document to enter it in a requirements link enters the location of the document with a fully specified absolute path. You can also enter a relative path for the document location. A relative path can be a partial path or no path at all. In many cases it is preferable to use a relative path so that the document is not constrained to a single location in the file system. With a relative path the Requirements Management Interface resolves the exact location of the requirements document in this order:
An attempt is made to resolve the path relative to the current MATLAB directory.
If there is no path specification and the document is not in the current directory, the MATLAB search path is used to locate the file.
If the document is not located relative to the current directory or the MATLAB search path, it is resolved relative to the model file directory.
The following examples illustrate the procedure for locating the specified requirements document.
Current MATLAB directory: | |
Model file: | |
Document link: | |
Documents searched for: |
Current MATLAB directory: | |
Model file: | |
Requirements document: | |
Documents searched for: | C:\work\scratch\pid.html |
Current MATLAB directory: | |
Model file: | |
Requirements document: | |
Documents searched for: |
You can add or delete requirement links for a selection of multiple Simulink blocks or Stateflow objects as follows:
In the my_sf_car model, select the Engine, engine RPM, and transmission blocks.

You can select multiple Simulink blocks or Stateflow objects in one of the following ways:
Hold down the Shift key while clicking each block.
Click and drag a selection rectangle around them.
Right-click any of the selected blocks and select Requirements > Add Links to All.
The Add Requirements dialog box appears, as shown, for the three selected blocks.

Add a new Requirement 3 for these blocks that points to the text "Tertiary Requirements" in the file requirements.doc.
Add the requirement as you would for a single block, as described in Adding Requirement Links to an Object.
Click Apply to apply the requirement links.
Click OK to close the Requirements dialog box.
In the my_sf_car model, click outside the three objects to deselect them.
Right-click the Engine block and select Requirements.
The Engine block now has three requirements, as shown.

Right-click the engine RPM and transmission blocks to verify that they have only one requirement—Requirement 3.
To delete the existing requirements for a group of selected blocks, right-click any of a group of selected blocks and, from the resulting context menu, select Requirements > Delete All. This deletes all the requirement links for all the selected blocks, whether they were added individually or as a group.
Selection-based linking is a quick way to create links between model elements and selected portions of a requirements document, which can be a Microsoft Word or Excel file only. This method creates a two-way link by embedding a Microsoft ActiveX control into the requirements document next to the selected string or cell.
Use the following procedure to configure selection-based linking:
Open the my_sf_car model, if necessary.
In the model window, select Tools > Requirements > Link settings. The Selection-based linking dialog box opens.

Select the check box next to Word if necessary.
Specify the following preferences on the Selection-based linking dialog box:
In the Document file reference drop-down list, specify how to store the document location. For more information, see Resolving the Document Path.
To create two-way links, select Modify documents to include links to models. Two-way linking embeds an ActiveX® control in your requirements document, which lets you navigate from the requirements document to the Simulink model and vice versa.
If you create two-way links the Model file reference drop-down list, specify how to locate the model when you navigate from a requirements document to the model using one of these two options:
none (on MATLAB path) — The model is located on the MATLAB path.
Absolute — Use the absolute path to locate the model.
Click OK to close the Selection-based linking dialog box.
Use the following procedure to create selection-based requirement links:
Right-click the Engine block and select Requirements > "Requirement 1".
requirements.doc opens in a Microsoft Word window.
Select a portion of the text that documents the desired requirement. For this example, select a "Dummy text." string.

In the Simulink model, right-click the Engine block and select Requirements > Add link to Word selection.
Note The Word document must be open and text must be selected for the Add link to Word selection option to work. If no Word document is open, you are asked to open a document or cancel the operation. |
The Requirement Management Interface creates the link. If you right-click the Engine block and select Requirements, the Engine block now has four requirement links.

If you select Requirements > Dummy text., a Microsoft Word window opens with the requirements document scrolled to the appropriate text.
If you configured two-way linking, an ActiveX control
is embedded in the requirements
document next to the selected string.

Click the ActiveX control to display the my_sf_car model, with the Engine block highlighted.

![]() | Configuring the Requirements Management Interface | Linking to Custom Types of Requirements Documents | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |