string = num2eng(valor,unidad)
'10mF' = num2eng(0.01,'F')
'10m' = num2eng(0.01)
Also available eng2num
Jordi Palacin (2020). num2eng (https://www.mathworks.com/matlabcentral/fileexchange/7614-num2eng), MATLAB Central File Exchange. Retrieved .
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