I'm searching for the reverse of this request
So when I type num2str(foo,3)
, I get this :
foo=0.00781
foo=0.0313
foo=0.125
foo=0.5
foo=2
foo=8
However I want to make them all of the same length, so something like this :
foo=0.0078
foo=0.0313
foo=0.1250
foo=0.5000
foo=2.0000
foo=8.0000
-How- can I do this with num2str
? (And I would really appreciate if it also works if mat2str
)
Thanks for any help!
Edit :
I noticed that there is another -yet unsolved- part to this problem, which is for numbers greater than 10, or 100, 1000, etc.
So what if I want this : ?
foo=000.5000
foo=002.0000
foo=008.0000
foo=032.0000
foo=128.0000
i.e. adding leading zeros to a specified length? I tried '%3.3f'
but it doesn't work.