Clear Filters
Clear Filters

Requirements Manager: How to extract information from the Custom Attribute Registry inside the Requirement Set class

11 views (last 30 days)
Hi all,
I have reached a good level of export requirements in the exel format using the guide indicated to me by the Matlab community: https://www.mathworks.com/help/slrequirements/ug/export-requirements-and-link-information-example.html
Now I would like to enrich the export by including the custom requirements. The method slreq.open('Name.slreqx') return me the requirement set structure but using the slreq.find() the custom attribute is not included. How can I achieve this, if it is possible? Thanks
Attached an image to show my sysReqSeqSet structure after running slreq.open('Req_TestMod_v2.slreqx') with two custom attributes added 'CustomAttributeNames', that I would like to export to the exel file along with the others.
Thank you in advance.

Accepted Answer

Pat Canny
Pat Canny on 20 Jun 2024
You can get an array of CustomAttributeNames as a property of a Requirement Set, then use inspectAttribute to query the Information for a given Custom Attribute.
Here is a quick example leveraging the example from the inspectAttribute page in our documentation:
slreq.load('crs_req_func_spec');
rs = slreq.find('Type','ReqSet');
addAttribute(rs,'MyCheckbox','Checkbox','Description',...
'This checkbox attribute can be true or false.');
addAttribute(rs,'MyEdit','Edit','Description',...
'This is an Edit field');
customAttributeNames = string(rs.CustomAttributeNames)';
customAttributeInfo = arrayfun(@(x) string(inspectAttribute(rs,customAttributeNames(x)).description), 1:numel(customAttributeNames))';
tableForExport = table(customAttributeNames,customAttributeInfo,'VariableNames',["Custom Attribute", "Info"])
From here you can use writetable to export to Excel.
  1 Comment
Luca
Luca on 21 Jun 2024
Thank you Pat, I understand your example that will be useful to me. I have to apologize though, I couldn't explain myself and focus on what I needed.
The canonical (slreq.Requirement) array structure of properties created within the reqXlsExport.m script through the slreq.find('Type','Requirement'); obviously not contain the fields of the my new custom requirements (requirement by requirement). Now i would to figure out how to extract the data associated to the my custom requirements values (requirement by requirement) if it is possible. After that i'll exported in the exel file, but this is another story. I hope I've explained myself better. Thank You.

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!