Main Content

mlreportgen.utils.units class

Package: mlreportgen.utils

Convert units

Description

The units class provides conversions between units.

Creation

Description

example

value = mlreportgen.utils.units.toPixels(lengthUnits) converts the specified lengthUnits to pixels. The lengthUnits has two parts. The length is the number of units, such as 5 or 8.3. The unit is the unit type, such as pixels or inches. You can also use a syntax with separate length and units: value = mlreportgen.utils.units.toPixels(length,units).

value = mlreportgen.utils.units.toPoints(lengthUnits) converts the specified lengthUnits to points. You can also use a syntax with separate length and units: value = mlreportgen.utils.units.toPoints(length,units).

value = mlreportgen.utils.units.toPoints... (length,units,"DPI",convFactor) uses the optional Name-Value pair to override the screen pixels to inches. This syntax can be used with any conversion syntax (that is, toPixels, toPoints, etc.)

value = mlreportgen.utils.units.toInches(lengthUnits) converts the specified lengthUnits to inches. You can also use a syntax with separate length and units: value = mlreportgen.utils.units.toInches(length,units).

value = mlreportgen.utils.units.toCentimeters(lengthUnits) converts the specified lengthUnits to centimeters. You can also use a syntax with separate length and units: value = mlreportgen.utils.units.toCentimeters(length,units).

value = mlreportgen.utils.units.toMillimeters(lengthUnits) converts the specified lengthUnits to millimeters. You can also use a syntax with separate length and units: value = mlreportgen.utils.units.toMillimeters(length,units).

value = mlreportgen.utils.units.toPicas(lengthUnits) converts the specified lengthUnits to picas. You can also use a syntax with separate length and units: value = mlreportgen.utils.units.toPicas(length,units).

Input Arguments

expand all

Measurement length and units to convert, specified as a string.

Example: "5in"

Length to convert, specified as a positive numeric value.

Example: 5 (as in (5,"in"))

Unit type to convert, specified as singular or plural units or a units abbreviation.

Units (singular)Units (plural)Abbreviation
inchinchesin
centimetercentimeterscm
millimetermillimetersmm
pixelpixelspx
picapicaspc
pointpointspt

Example: "5in", "5inch", or "5inches"

Conversion factor for overriding screen pixels to inches, specified as a positive numeric value. Use a Name-Value pair, where "DPI" is the Name character vector or string and dpi is the number of dots per inch. This input is optional.

Examples

collapse all

value = mlreportgen.utils.units.toPixels("5in");
value = mlreportgen.utils.units.toPoints("8.3cm"); 
value = mlreportgen.utils.units.toMillimeters(3,"in");
value = mlreportgen.utils.units.toPicas(7,"pt");
value = mlreportgen.utils.units.toInches(3,"in",...
     "DPI",96);

Version History

Introduced in R2018b