Format numbers in vector with leading zero: 1 -> 01
이전 댓글 표시
Is there a way to format a number in Matlab with leading zero?
Suppose I have a number 1, so it would be 01. I need to obtain a number representation of some strings with letters converted into numbers with leading zeros.
답변 (1개)
the cyclist
2016년 5월 17일
sprintf('%02d',1)
댓글 수: 3
Stepan Ulyanin
2016년 5월 17일
the cyclist
2016년 5월 17일
Despite the name, it is not "just printing". It is creating a variable that is the string. You can combine them however you want. For example
s1 = [sprintf('%02d',1),sprintf('%02d',7)]
Stepan Ulyanin
2016년 5월 17일
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!