File Exchange

image thumbnail


version (2.05 KB) by Carlos Adrian Vargas Aguilera
Same as int2str but with zero padding to the left.


Updated 04 May 2016

View License

This is a really simple program that makes the same as int2str but pads with zeros those integers with less digits than the maximum one.
It is useful (I hope) when our program reads files with names like: xxx001.dat, xxx002.dat, ..., xxx099.dat, xxx100.dat, etc., and we don't want to make use of if's to put zeros to int2str outputs (great isn't it).

int2strz(X,N) pads up to N digits (see the screenshot).

Cite As

Carlos Adrian Vargas Aguilera (2020). int2strz.m (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (5)

Eric Bunker

Brien Polk

i use it all the time... thank you

Fco. Camacho

Yes jerome, but for us that doesn't like or want to write or read or simply don't understand thinks like '%..d', this is a beauty option and more readable. Question: why you don't complain about the int2str(x) function? We can do the same with num2str(round(x)) don't you think???

Jérôme Briot

Sorry, should read :



Jérôme Briot

Did you look at the documentation ?

X=[0 1 11 111]'

% or

IMHO, you should remove this submission.

MATLAB Release Compatibility
Created with R2007b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: daylightGMT.m

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!