File Exchange

image thumbnail

num2eng

version 1.0.0.0 (1.35 KB) by Jordi Palacin
Number representation with engineering units.

0 Downloads

Updated 10 May 2005

View License

Engineering representation:

string = num2eng(valor,unidad)
'10mF' = num2eng(0.01,'F')
'10m' = num2eng(0.01)

Also available eng2num

Comments and Ratings (2)

This submission has several major issues that need to be fixed, in particular:
- it goes into an infinite loop if the input is zero, negative or +-Inf.
- any value with a magnitude less than -15 is returned only as '0.000f'... why did my data disappear?
- any value with a magnitude greater than 18 only adds more zeros, eg 1e22 -> '10000000P' (should be '10 Z').
- Capital 'K' should be lower case 'k' for the prefix 'kilo'.
- NaN -> 'NaNm'
- [] -> 'm'
The lack of an H1 line, help section and input/output description, several "mlint" messages that need attention and repeated code indicates that this function could do with a tidy-up. Some input checking is required and precision control would be nice too, although on the plus side, those examples are handy.

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 on FX
http://www.mathworks.com/matlabcentral/fileexchange/33174

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