MATLAB: Very simple logical question

numbers

Hello all
I want to generate the set of numbers such that each number is having the same number of digits.
Something like this: 0001,0002,0003,…..0010,0011,0012,…..0100,0101,0102…..,0998,0999,1000
can anyone please help me with this?
Regards

Best Answer

arrayfun(@(x)sprintf('%04d',x),1:1000,'un',0);
or
reshape(sprintf('%04d',1:1000),4,[])'