Main Content

Author Requirements for MATLAB Function

A requirement describes behavior that a design must satisfy. Requirements typically take the form of natural language statements, formulas, tables, and graphics. In Requirements Toolbox™, you use the Requirements Editor to author requirements and create requirement sets to contain the requirements.

In this step of the tutorial, you author requirements that describe the required behavior of a MATLAB® function that adds two numbers.

Describe Required Behavior

In this example, the functional behavior of the function must meet these requirements:

  • The function shall take two numerical inputs.

  • The function shall add the two inputs.

  • The function shall output the result of the addition.

Additionally, the function must check the inputs:

  • The function shall not allow inputs of Inf or NaN.

Author Requirements in the Requirements Editor

Author the requirements in Requirements Toolbox by using the Requirements Editor. First, open the MyAdd project so that you can save the requirement set in the project.

openProject("MyAdd");

Open the Requirements Editor. In the Apps tab, under Verification, Validation, and Test, click Requirements Editor.

Create a new requirement set by clicking New Requirement Set. Name the requirement set myAddReqs and save the requirement set in the documents folder of the MyAdd project.

The Requirements Editor shows the myAddReqs requirement set, which has no requirements.

Add a requirement to the requirement set by selecting the requirement set and clicking Add Requirement. In the right pane, add information to the Summary property and Description property using the text from the requirements:

  • Summary: Take two inputs

  • Description: The function shall take two numerical inputs.

The Summary property is a short phrase that identifies the requirement. The Description property contains detailed information about the required behavior.

Requirement 1 in the myAddReqs requirement set is selected in the Requirements Editor and its Summary and Description properties are shown.

Add a second requirement with this summary and description:

  • Summary: Add the inputs

  • Description: The function shall add the two inputs.

Add a third requirement with this summary and description:

  • Summary: Output the result

  • Description: The function shall output the result of the addition.

Add a fourth requirement with this summary and description:

  • Summary: Inputs should be finite

  • Description: The function shall not allow inputs of Inf or NaN.

The myAddReqs requirement set and its four requirements and requirement summaries are shown as they appear in the Requirements Editor.

Save the changes to the requirement set by clicking Save.

See Also

Apps

Classes