create a string like "AA";"BB";"CC";"DD", and so on

6 ビュー (過去 30 日間)
Alberto Acri
Alberto Acri 2023 年 9 月 24 日
コメント済み: Dyuman Joshi 2023 年 9 月 24 日
Hi! I would like to create a string like "AA";"BB";"CC";"DD",and so on.
The idea is similar to this:
letters_str = string(mat2cell('A':'Z',1,ones(1,26)))';
I would simply like to double the letters in 'letters_str'.

採用された回答

Dyuman Joshi
Dyuman Joshi 2023 年 9 月 24 日
str = string(char('AA' + repmat((0:25)',1,2)))
str = 26×1 string array
"AA" "BB" "CC" "DD" "EE" "FF" "GG" "HH" "II" "JJ" "KK" "LL" "MM" "NN" "OO" "PP" "QQ" "RR" "SS" "TT" "UU" "VV" "WW" "XX" "YY" "ZZ"
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 9 月 24 日
Another idea -
str = string(('A':'Z')');
str = join([str str],'')
str = 26×1 string array
"AA" "BB" "CC" "DD" "EE" "FF" "GG" "HH" "II" "JJ" "KK" "LL" "MM" "NN" "OO" "PP" "QQ" "RR" "SS" "TT" "UU" "VV" "WW" "XX" "YY" "ZZ"

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by