Requirement Traceability in Simulink: How to Use It Effectively
In
Simulink, requirement traceability is done by linking Requirement objects to model elements using the Requirements Toolbox. You create requirements, link them to blocks or subsystems, and then use traceability reports to verify coverage and compliance.Syntax
Requirement traceability in Simulink involves these main steps:
req = reqmgr.create('RequirementName'): Create a requirement object.link = reqmgr.link(req, modelElement): Link the requirement to a model element like a block or subsystem.report = reqmgr.generateTraceabilityReport(): Generate a report showing linked requirements and coverage.
Here, reqmgr is the Requirements Manager interface in Simulink.
matlab
reqmgr = slreq.requirements.Manager.getInstance(); req = reqmgr.create('SpeedControlReq'); modelElement = 'myModel/SpeedController'; link = reqmgr.link(req, modelElement); report = reqmgr.generateTraceabilityReport();
Example
This example shows how to create a requirement, link it to a Simulink block, and generate a traceability report.
matlab
reqmgr = slreq.requirements.Manager.getInstance(); % Create a new requirement req = reqmgr.create('MaxSpeedLimit'); req.Text = 'The system shall not exceed 120 km/h.'; % Specify the model and block to link modelName = 'speedControlModel'; load_system(modelName); blockPath = [modelName '/SpeedLimiter']; % Link the requirement to the block link = reqmgr.link(req, blockPath); % Generate and open the traceability report report = reqmgr.generateTraceabilityReport(); open(report);
Output
A traceability report window opens showing the 'MaxSpeedLimit' requirement linked to the 'SpeedLimiter' block in the 'speedControlModel'.
Common Pitfalls
- Not loading the Simulink model before linking requirements causes errors.
- Linking requirements to incorrect or non-existent model elements leads to broken traceability.
- Forgetting to save the model or requirements manager state can lose links.
- Using inconsistent naming for requirements makes tracking difficult.
Always verify the model is open and the block path is correct before linking.
matlab
reqmgr = slreq.requirements.Manager.getInstance(); req = reqmgr.create('SafetyReq'); % Wrong: Model not loaded % link = reqmgr.link(req, 'myModel/NonExistentBlock'); % Causes error % Correct: load_system('myModel'); link = reqmgr.link(req, 'myModel/ExistingBlock');
Quick Reference
| Action | Command/Method | Description |
|---|---|---|
| Create Requirement | reqmgr.create('ReqName') | Creates a new requirement object |
| Set Requirement Text | req.Text = 'Description' | Defines the requirement details |
| Link Requirement | reqmgr.link(req, 'Model/Block') | Links requirement to model element |
| Generate Report | reqmgr.generateTraceabilityReport() | Creates traceability report |
| Open Model | load_system('ModelName') | Loads Simulink model before linking |
Key Takeaways
Use the Requirements Manager in Simulink to create and manage requirements.
Always load your Simulink model before linking requirements to blocks or subsystems.
Link requirements directly to model elements for clear traceability.
Generate traceability reports to verify requirement coverage and compliance.
Avoid broken links by verifying model element paths and saving your work.