num2strUP
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Text/Strs/Chars/Links
Introduced first in SolidGeometry 5.0, Creation date: 2021-01-16, Last change: 2025-09-15
creates a string containing a unit prefix
Description
In many graphical outputs, numbers in type 1e-5 are unfortunate because they are difficult to read. Likewise with time specifications the range under 120 seconds is represented differently than over 120 seconds. This function generates unit prefixes considering some peculiarities
https://de.wikipedia.org/wiki/Vorsätze_für_MaÃeinheiten
See Also: , meanGauss
, roundgauss
, num2strCNT
Example Illustration
Syntax
sstr=num2strUP(instr,[unit,dig,cut0])
Input Parameter
instr: | | number or string |
unit: | | number unit such as "Pa" or 's' or 'sec' |
dig: | | digits behind comma |
cut0: | | if true, ending zeros are cut; default is false |
Output Parameter
sstr: | | final number string |
Examples
s=num2strUP(12300,'Pa',3) % 3 Digits in Pascal
s=num2strUP(12300,'Pa',3,true) % 3 Digits in Pascal with cut zeros
s=num2strUP(exp(1)*1234,'Pa',3) % 3 Digits in Pascal
s=num2strUP(exp(1)/1234,'Pa',3) % 3 Digits in Pascal
s=num2strUP(exp(1)*1234,'sec',3) % 3 Digits in Seconds
s=num2strUP(exp(1)/1234,'sec',3) % 3 Digits in Seconds
Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Last html export of this page out of FM database by TL: 2025-09-21