Borrar filtros
Borrar filtros

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

11 visualizaciones (últimos 30 días)
Alberto Acri
Alberto Acri el 24 de Sept. de 2023
Comentada: Dyuman Joshi el 24 de Sept. de 2023
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'.

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 24 de Sept. de 2023
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 comentario
Dyuman Joshi
Dyuman Joshi el 24 de Sept. de 2023
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"

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by