Main Content

mlreportgen.dom.setDefaultNumberFormat

Set default formatting of numeric data generated by DOM API

Since R2021a

Description

mlreportgen.dom.setDefaultNumberFormat(formatSpec) sets the default number format specification for the DOM API. The default specification applies for the duration of the MATLAB® session and applies to numbers in document elements, such as paragraphs, tables, and lists, and to numbers represented as mlreportgen.dom.Number objects. You can override the default specification for one number or all numbers in the document element by using an mlreportgen.dom.NumberFormat object.

example

Examples

collapse all

Set the default number format for the MATLAB session.

import mlreportgen.dom.*
setDefaultNumberFormat("%0.2f");

Create a report and include a number with the default format in the report.

rpt = Document("Report with setDefaultNumberFormat","pdf");

n = Number(pi);
append(rpt,n);

close(rpt);
rptview(rpt);

Input Arguments

collapse all

Format specification, specified as a character vector or string scalar. The specification must be a valid format specification for the sprintf function and use one of these operators:

  • %f

  • %e

  • %E

  • %g

  • %G

Example: "%0.2f"

Version History

Introduced in R2021a