How do I add variables into a string within a table?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a table with a column of 10 digit strings that I need to add "-" into.
How do I turn a column of strings looking like this "0001336363" into a column of strings looking like this "0001336-36-3"?
댓글 수: 0
채택된 답변
Star Strider
2020년 10월 20일
The only option appears to be to turn the string variable into a char array first:
str = "0001336363";
strc = char(str);
Out = sprintf("%7s-%2s-%s", strc(1:7),strc(8:9),strc(10))
producing:
Out =
"0001336-36-3"
.
댓글 수: 2
Star Strider
2020년 10월 20일
As always, my pleasure!
I searched through the string functions, although I didn’t consider that insertAfter would apply. It would likely come down to which is the more efficient use of computer resources.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!