Very simple logical question
Ältere Kommentare anzeigen
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 Kommentare
Patrik Ek
am 7 Aug. 2014
Do they have to be of any numerical type, or is it ok to have them as a char vector?
Sameer
am 7 Aug. 2014
Patrik Ek
am 7 Aug. 2014
Ok I do not think char is the only possiblility, that is why I asked. I would recommend this solution by Andrei Bobrov.
Akzeptierte Antwort
Weitere Antworten (1)
Ben11
am 7 Aug. 2014
A = cell(1,1000);
for k = 1:1000
A{k} = sprintf('%04d',k);
end
Kategorien
Mehr zu Simulink finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!