フィルターのクリア

How to add string to the beginning of each element in a string array?

2 ビュー (過去 30 日間)
Ana Alonso
Ana Alonso 2018 年 12 月 12 日
コメント済み: Ana Alonso 2018 年 12 月 12 日
Hi there,
I'm trying to append a string to the beginning of each element in a string array. Specifically, I'd like to add the text "Syl_" such that I can turn the string array s1 into the string array s2.
s1 = string(1:4)
1×4 string array
"1" "2" "3" "4"
s2 = ["Syl_1", "Syl_2", "Syl_3", "Syl_4"]
1×4 string array
"Syl_1" "Syl_2" "Syl_3" "Syl_4"

採用された回答

Cris LaPierre
Cris LaPierre 2018 年 12 月 12 日
s2 = "Syl_" + s1

その他の回答 (1 件)

Mark Sherstan
Mark Sherstan 2018 年 12 月 12 日
Give this a try:
s1 = string(1:4);
s2 = strcat('Syl_',s1)
  1 件のコメント
Ana Alonso
Ana Alonso 2018 年 12 月 12 日
Thank you so much! I didn't realize strcat read in arrays.

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

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by