String manipulation (adding additional characters and spaces)

2 ビュー (過去 30 日間)
Florian
Florian 2020 年 5 月 9 日
コメント済み: Florian 2020 年 5 月 9 日
tostr = [3 14; 4 38; 5 25; 15 1; 16 196];
str=num2str(tostr);
How can I modify the above created string 'str' into the following (example for row 1):
'F 3 (n 14) ' (with a space after the last bracket)
and then concatenate the different rows into one single string:
'F 3 (n 14) F 4 (n 38) F 5 (n 25) F 15 (n 1) F 16 (n 196)'

採用された回答

Walter Roberson
Walter Roberson 2020 年 5 月 9 日
strjoin(compose('F %d (n %d)', tostr))

その他の回答 (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