MATLAB: Print numbers in Enginering Notation

engineering notation

Hi everyone,
I need to print out in a txt file a list of numbers, one for each row, with this format:
i.dddddddddddddde+000 hence 1digit before decimal separator, 14 after that and 3 for the exponent.
Could anyone help me?
Thanks,
Stefano

Best Answer

Separate the mantissa and the exponent
Values = [pi ; 1.12301230123e17 ; 100000 ; 9999999999999]
E = floor(log10(Values)) % exponent
M = Values ./ (10.^E) % mantissa
TMP = [M(:) E(:)].'
fprintf('%1.14fe%03d\n', TMP)