Super and Subscripts for viewing within Matlab Reports?

10 次查看(过去 30 天)
Hi All,
I've generated some reports to call the below code:
textForItem1 = Text(['Conductor Size Chosen = ',num2str(C),' mm^2']); step2 = ListItem(textForItem1);
I've appended the ordered list, procedure to the relevant section. All seems fine.
When the report is generated I get exactly mm^2 where as I want it the 2 to be superscripted. Ive tried additional code str, strcat, fprint etc to no avail?
I guess I need some code which assigns a str/variable and calls the conductor size (C, an integer) the text (mm^2, 2 superscripted)and then implement this in the above code as num2str() and remove the ' mm^2'.
Any ideas much appreciated.
Frank

回答(1 个)

Jaswanth
Jaswanth 2024-8-2,15:18
Hi,
To create a superscript "2" in your report, you need to create separate text elements and apply the superscript style to the "2". You can achieve this by using the Format Object of MATLAB Report Generator's DOM API. A format object is a MATLAB® object that defines the properties and functions of a document format such as a font family or size. The DOM API provides a set of constructors for creating format objects corresponding to most of the formatting options available in HTML, Word, and PDF documents.
To generate report with superscript or subscript formatting, you need to use VerticalAlign Format Object. Please refer to the following code snippet on implementing the solution discussed above:
conductorSizeText = Text(['Conductor Size Chosen = ', num2str(C), ' mm']);
superScriptText = Text('2');
superScriptText.Style = {VerticalAlign('superscript')};
Please refer to the following MathWorks documentation on Format Text in MATLAB Report Generator to know more on formatting text programmatically, using DOM format objects: https://www.mathworks.com/help/rptgen/ug/create-and-format-text.html#:~:text=rptview(%27test%27%2C%27html%27)%3B-,Format%20Text,-You%20can%20format
I hope the information provided above is helpful.

类别

Help CenterFile Exchange 中查找有关 Reporting and Database Access 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by