Issue on sprintf in Matlab
-
06-02-2021 - |
Question
How to print in Matlab Like following....
0.01000E+02
I have tried
sprintf('%12.5e',[0.01000E+02])
it is giving me
1.00000e+000
Solution
You format is a bit specific. You should consider writing your own output function.
But a few pointers:
- Make e large with
upper
- only 2 digits in exp number through a regexp.
new_string = regexprep(old_string,'\d(\d{2})$','\1')
- the thing with leading 0 in exp representation is not standard - so maybe multiply with
1e2
, print the float and later attach theE+02
.
OTHER TIPS
Something like ['0.0' strrep(sprintf('%12.5E',v*100), '.', '')]
(with v
your value) should work if I understand correctly your format.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow