user974194
user974194

Reputation: 3

Issue on sprintf in Matlab

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

Upvotes: 0

Views: 276

Answers (2)

Clement J.
Clement J.

Reputation: 3032

Something like ['0.0' strrep(sprintf('%12.5E',v*100), '.', '')] (with v your value) should work if I understand correctly your format.

Upvotes: 1

bdecaf
bdecaf

Reputation: 4732

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 the E+02.

Upvotes: 1

Related Questions