Main Content


Class: slreq.ReqSet
Namespace: slreq

Assign PreSaveFcn callback script

Since R2022a




setPreSaveFcn(rs,callbackScript) assigns the script specified by callbackScript as the PreSaveFcn callback script for the requirement set rs.

Input Arguments

expand all

Requirement set, specified as an slreq.ReqSet object.

Name of the script to register as the PreSaveFcn callback for the requirement set, specified as a string scalar or 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