From: Kean Foster on
Hi,

I need some help. Is there a simple way to convert a number to a string that always has a certain number of digits ie. 1 becomes 01.

Cheers
Kean
From: Jan Simon on
Dear Kean!
> I need some help. Is there a simple way to convert a number to a string that always has a certain number of digits ie. 1 becomes 01.

sprintf('%.3d', 1)
>> ans=
001

Good luck, Jan
From: Kean Foster on
Thanks Jan, works a treat!

"Jan Simon" <matlab.THIS_YEAR(a)nMINUSsimon.de> wrote in message <hvab73$i4o$1(a)fred.mathworks.com>...
> Dear Kean!
> > I need some help. Is there a simple way to convert a number to a string that always has a certain number of digits ie. 1 becomes 01.
>
> sprintf('%.3d', 1)
> >> ans=
> 001
>
> Good luck, Jan