string = num2eng(valor,unidad)
'10mF' = num2eng(0.01,'F')
'10m' = num2eng(0.01)
Also available eng2num
Jordi Palacin (2021). num2eng (https://www.mathworks.com/matlabcentral/fileexchange/7614-num2eng), MATLAB Central File Exchange. Retrieved .
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, and extensive control over the formatting of the output string:
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
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!