Simple question with string
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a string, and I want to add a character after the 4th element of this string, for example:
str1='noteook';
I want to obtain
str2='notebook';
so placing a 'b' after the 4th character. I want to do this starting from the beginning and not from the end of the string, since I have to do this for more strings which have different length (while the element I want to insert is always the 5th one). thanks!
댓글 수: 0
채택된 답변
Adam
2015년 3월 19일
strcat( str1(1:4), 'b', str1(5:end) )
will do the job, amongst other alternatives, with the obvious generalisation of replacing the hard-coded 4, 5
추가 답변 (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!