How to filter view on Comments inside of Requirements Toolbox

34 ビュー (過去 30 日間)
Psych
Psych 2025 年 10 月 22 日 22:03
回答済み: Josh Kahn 2025 年 10 月 23 日 20:32
I'm using MATLAB R2023b Update 6 (not sure what the Requirements Toolbox version is).
Could someone please help me create a view that filters on the comment field that includes any amount of text?
Specifically, I want to make a view and filter on items that have a comment present as shown below.
MATLAB documentation (slreq.Requirement - Work with requirement objects - MATLAB) says that the property Comments is an array structure. The fields of the Comments struct are Comments.CommentedBy, Comments.CommentedOn, Comments.CommentedRevision, and Comments.Text.
I am trying to filter using Comments.Text but I cannot figure it out. The filter I made that doesn't work is:
{"Comments.Text:~=" , ""};
The error that I receive is "Error applying Requirements view filter: No such attribute." I have also tried many different permutations to no avail.

回答 (1 件)

Josh Kahn
Josh Kahn 2025 年 10 月 23 日 20:32
Please let me know if this gets you what you need:
allReqs = slreq.find("Type", "Requirement");
emptyComments = cellfun(@isempty, {allReqs.Comments});
idList = strjoin({allReqs(emptyComments).Index}, "|");
selectionString = compose("^%s$", idList);
{"Index:regexp", selectionString};

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by