필터 지우기
필터 지우기

Concatenate Aphabets and numbers

조회 수: 1 (최근 30일)
joseph Frank
joseph Frank 2013년 8월 26일
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'

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 26일
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)

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2013년 8월 26일
az = cellstr(('a':'z')');
n = numel(az);
[ii,jj] = ndgrid(1:n);
a1 = [az;strcat(az(jj(:)),az(ii(:)))];
out = strcat(a1,'2');

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by