Is there a function to do this?
显示 更早的评论
回答(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
2018-1-8
With this, will you be able to work out the function?
>> sprintf('%04d',12)
ans =
'0012'
类别
在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!