in matlab, num2str
command converts numbers strings.
a format input allowed permits user number format,
including options zero-padding , precision.
is there way create string zero-pads number left
, permits specified decimal precision?
i'm not getting results demonstrate this:
examples of problem
input:
num2str(1.2,'%04f')
output:
1.200000
input:
num2str(1.2,'%04.f')
output:
0001
input:
num2str(1.2,'%04.2f')
output:
1.20
note zero-padding occurs in specific format.
desired behavior
input:
num2str(1.2,'%04.2f')
output:
0001.20
write:
num2str(1.2,'%07.2f')
the number befor .
total number of digits + .
.
so 7.2
means: 7 total characters, them 2 after .
.
Comments
Post a Comment