Create Requirement Set File by Using the Simulink® Requirements™ API

This example shows how to use the Simulink® Requirements™ API to create a requirement set with a custom hierarchy and custom requirement types. You create a requirement set as an .slreqx file. You can distribute the .slreqx file across your organization.

You can integrate the requirement set file into a change management system that users can use as a parent document to create their own requirement sets.

Requirement Set Hierarchy

The requirement set that you create in this example contains two top-level parent requirements and parent justifications for implementation and verification. The requirement set follows this hierarchical structure.

Create Requirement Set

Navigate to the folder where you want to create the requirement set. Create a requirement set my_New_Req_Set with handle myReqSet by using the slreq.new() function.

myReqSet = slreq.new('my_New_Req_Set');

Add System Requirements to the Requirement Set

Add a top-level Container requirement for System Requirements to the requirement set

myParentReq1 = add(myReqSet,'Id','R1', ...
    'Summary','System Requirements', ...
    'Type', 'Container');

Create child requirements for R1.

childReqR11 = add(myParentReq1,'Id','R1.1');
childReqR12 = add(myParentReq1,'Id','R1.2');

Create child requirements for R1.1.

childReqR111 = add(childReqR11,'Id','R1.1.1');
childReqR112 = add(childReqR11,'Id','R1.1.2');
childReqR113 = add(childReqR11,'Id','R1.1.3');

Create a child requirement for R1.1.3.

childReqR1131 = add(childReqR113,'Id','R1.1.3.1');

Add Safety Requirements to the Requirement Set

Add a top-level Safety requirement to the requirement set. Safety requirements are informational and do not contribute to the Implementation and Verification status summaries. In this example, you define a custom requirement type that extends the Informational requirement type by using the sl_customization.m file.

Refresh customizations to add the Safety requirement type to the list of requirement types.

sl_refresh_customizations;

Create the parent safety requirement.

myParentReq2 = add(myReqSet,'Id','R2', ...
    'Summary','Safety Requirements', ...
    'Type','Safety');

Create child requirements for R2.

childReqR21 = add(myParentReq2,'Id','R2.1');
childReqR22 = add(myParentReq2,'Id','R2.2');

Create child requirements for R2.2.

childReqR221 = add(childReqR22,'Id','R2.2.1');
childReqR222 = add(childReqR22,'Id','R2.2.2');
childReqR223 = add(childReqR22,'Id','R2.2.3');

Add Justifications to the Requirement Set

Create the parent justification.

myParentJustification = addJustification(myReqSet,'Id','J', ...
    'Summary','Requirement Justifications');

Add child justifications to the parent justification J to justify requirements for Implementation

childJust1 = add(myParentJustification,'Id','J1', ...
    'Summary','Implementation Justifications');

Add child justifications to the parent justification J to justify requirements for Verification

childJust2 = add(myParentJustification,'Id','J2', ...
    'Summary','Verification Justifications');

Save the Requirement Set

save(myReqSet);