Very simple logical question
3 次查看(过去 30 天)
显示 更早的评论
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
3 个评论
Patrik Ek
2014-8-7
Ok I do not think char is the only possiblility, that is why I asked. I would recommend this solution by Andrei Bobrov.
采纳的回答
Andrei Bobrov
2014-8-7
编辑:Andrei Bobrov
2014-8-7
arrayfun(@(x)sprintf('%04d',x),1:1000,'un',0);
or
reshape(sprintf('%04d',1:1000),4,[])'
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!