Main Content


Class: slreq.ReqSet
Namespace: slreq

Get contents of PreSaveFcn callback

Since R2022a


callback = getPreSaveFcn(rs)


callback = getPreSaveFcn(rs) returns the contents of the PreSaveFcn callback for the requirement set rs.

Input Arguments

expand all

Requirement set, specified as an slreq.ReqSet object.

Output Arguments

expand all

Contents of the PreSaveFcn callback for the requirement set, returned as a character vector.


expand all

This example shows how to get and set the PreSaveFcn callback for a requirement set.

Add the current folder to the path.


Open the ShortestPath project that contains an algorithm to calculate the shortest path between two nodes on a graph. For more information, see Verify a MATLAB Algorithm by Using Requirements-Based Tests.


Open the shortest_path_tests_reqs requirement set. The requirement set contains test requirements that describe the functional behavior that must be tested by a test case in order to verify the shortest_path algorithm in the project.

testReqs ="shortest_path_tests_reqs");

Register the preSaveTestReqs script as the PreSaveFcn callback.


Confirm that the preSaveTestReqs script is the PreSaveFcn callback for the shortest_path_tests_reqs requirement set.

callbackScript = getPreSaveFcn(testReqs)
callbackScript = 

Save the shortest_path_tests_reqs requirement set to execute the callback.


The preSaveTestReqs script saves the current Requirements Editor view settings to a MAT-file called myViewSettings.mat.

type preSaveTestReqs.m

Version History

Introduced in R2022a