Is there an API to insert images into the requirement description?
12 views (last 30 days)
Show older comments
MathWorks Support Team
on 9 Jan 2026 at 0:00
Answered: MathWorks Support Team
on 9 Jan 2026 at 8:29
Is there an API to insert images into the requirement description?

Accepted Answer
MathWorks Support Team
on 9 Jan 2026 at 0:00
There is currently no API available that directly performs the same image insertion function as the insert image button in the Properties pane of the Requirements Editor.
However, there is an API that allows you to set rich text (HTML) in the Description and Rationale fields of a requirement. By embedding an image as a Base64-encoded Data URI within an <img> tag, you can achieve the same visual result.
rs = slreq.new('image_in_description.slreqx');
req = add(rs, Summary="sample");
pngFile = fullfile(pwd, 'Image1.png');
fid = fopen(pngFile, 'rb');
bytes = fread(fid, '*uint8');
fclose(fid);
b64 = matlab.net.base64encode(bytes);
datauri = "data:image/png;base64," + b64;
html = [ ...
"<p>Insert Image:</p>", ...
"<figure>", ...
"<img src=""" + datauri + """ alt=""embedded image"" width=""480"">", ...
"</figure>" ...
];
req.Description = strjoin(html, newline);
save(rs);
0 Comments
More Answers (0)
See Also
Categories
Find more on Author Requirements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!