Is there a function to do this?
Ältere Kommentare anzeigen
f(number,chars);
f(12,4) = '0012';
Antworten (3)
There is no need to manipulate the format string, it is much simpler to use the '*' option:
>> sprintf('%0*d',4,12)
ans = 0012
Fangjun Jiang
am 8 Jan. 2018
With this, will you be able to work out the function?
>> sprintf('%04d',12)
ans =
'0012'
Kategorien
Mehr zu Characters and Strings 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!