How can I insert a variable in a paragraph using Report Generator?

I've been working with Report Generator for several days now, but i haven't been able to figure out how to insert a variable (previously defined in the workspace) into a paragraph.
p03=Paragraph('Value is %0.5e',a);
p03=Paragraph('Value is %<a>');
Doesn't work, since it doesn't seem to work like it does when doing sprintf, and %<a> doesn't work either. Is there anyway to do so, or any easy workarounds to include a variable combined with text that doesn't involve using Paragraph? Thank you in advance.

回答 (2 件)

Rahul Singhal
Rahul Singhal 2019 年 3 月 29 日

0 投票

You can report on a variable using mlreportgen.report.MATLABVariable reporter class.
Paul Kinnucan
Paul Kinnucan 2019 年 4 月 1 日

0 投票

If the value of the variable is a string or scalar, you can do the following:
p03=Paragraph(sprintf('Value is %0.5e',a));
This works because sprintf returns a string, which the Paragraph constructor wraps in a Text object and adds to the paragraph object it creates.

質問済み:

2019 年 3 月 29 日

回答済み:

2019 年 4 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by