Concatenate Aphabets and numbers

2 visualizaciones (últimos 30 días)
joseph Frank
joseph Frank el 26 de Ag. de 2013
Hi,
I am trying the following code:
Alphabet=char('a'+(1:26)-1)';
[I,J]=ndgrid(1:26,1:26);
I=I'; J=J';
XX=[Alphabet(I(:)), Alphabet(J(:))];
XX=strvcat(Alphabet,XX);
Rw='2';
Rw=repmat(Rw,length(XX),1);
XX2=strcat([XX,Rw]);
I am ending up with a space between the alphabets and 2. How can I get rid of that? i.e. I want 'a2' instead of 'a 2'

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 26 de Ag. de 2013
Alphabet=('a':'z')'
n=numel(Alphabet)
[I,J]=ndgrid(1:n,1:n)
I=I'; J=J';
XX=cellstr([Alphabet(I(:)), Alphabet(J(:))])
XX=[cellstr(Alphabet);XX]
Rw='2';
XX2=cellfun(@(x) [x Rw],XX,'un',0)

Más respuestas (1)

Andrei Bobrov
Andrei Bobrov el 26 de Ag. de 2013
az = cellstr(('a':'z')');
n = numel(az);
[ii,jj] = ndgrid(1:n);
a1 = [az;strcat(az(jj(:)),az(ii(:)))];
out = strcat(a1,'2');

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by