MATLAB: Formating String Parameter Left of Decimal

sprintfstringvariable

In the following code, I want to create the str variable to read: Radius=100E-6 meter
However, I keep getting: Radius=1.00E-4 meter
I can't seem to force it to place more digits to the left of the decimal. How do I revise sprintf to produce the former instead of the latter?
a=100E-6;
str=sprintf('Radius=%3.0E meter,',a);
I know the answer is probably something simple, but I just can't seem to figure it out.
Thanks in advance,
M Ridzon

Best Answer

I wrote a little utility function for my own purposes to do this a while ago:
engstr = @(x) [x*10.^(-3*floor(log10(abs(x))/3)) 3*floor(log10(abs(x))/3)]; % Engineering Notation Mantissa & Exponent
x = 1E-4;
Result = sprintf('%3.0fE%-.0f', engstr(x))
Result =
'100E-6'
Configure the sprintf format string to produce the output you want.