フィルターのクリア

Simple question with string

2 ビュー (過去 30 日間)
aurc89
aurc89 2015 年 3 月 19 日
コメント済み: aurc89 2015 年 3 月 19 日
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!

採用された回答

Adam
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
  1 件のコメント
aurc89
aurc89 2015 年 3 月 19 日
Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by