File Exchange

## num2eng

version 1.0.0.0 (1.3 KB) by
Convert number to eng. notation string, with SI prefixes

Updated 29 Nov 2006

Convert numbers to engineering notation strings, with prefixes from International System of Units (SI).
Examples:
- num2eng(23e8) produces the string '2.3G'
- num2eng(0.0000004) produces the string '400n'

### Cite As

Federico Forte (2021). num2eng (https://www.mathworks.com/matlabcentral/fileexchange/13168-num2eng), MATLAB Central File Exchange. Retrieved .

Harry Dymond

SI prefixes are not engineering notation. Engineering notation is scientific notation with the exponent restricted to being an integer multiple of three. For those needing actual engineering notation, my num2eng function offers both engineering notation and SI prefixes:

https://uk.mathworks.com/matlabcentral/fileexchange/67740-num2eng

Stephen Cobeldick

Disclaimer: In the end I could not find any FEX submission that gave the correct outputs for the wide range of test-cases that I tried, so I ended up writing my own function. You can find it here:
http://www.mathworks.com/matlabcentral/fileexchange/33174

Stephen Cobeldick

Of all the numeric->prefix M-files the I reviewed, this has the simplest and clearest code, and the author even remembered to place a limit on the "while" loop iterations. It also includes an H1 line and some examples, which is nice. There are mlint messages that need attention, and some input checking and precision control is required (maybe just pass it directly to "num2str"?). A space character between the coefficient and prefix is required by the SI standard, but is missing from this submission, which makes it useless for publishing. Some strings are suboptimal: zero, +-Inf, and NaN all end up with the prefix y (eg: 0 -> '0y'), any value with an order > 27 just adds more zeroes (eg: 1e30 -> '100000000Y'), while values with an order < -28 end up with a messy combination of E-notation and SI prefix (eg: 1e-30 -> '1e-06y').

Lars Olav Vestland

A similar funtion can found at :
http://www.mathworks.com/matlabcentral/fileexchange/20950-num2str-with-metric-prefix
which have spacing between the SI-prefix and number, (as it should have).

Antoni J. Canós

Good job. Maybe some checking instructions are needed. It would be nice if you also submitted the "opposite" function eng2num!.

##### MATLAB Release Compatibility
Created with R10
Compatible with any release
##### Platform Compatibility
Windows macOS Linux