Concatenate Aphabets and numbers
1 次查看(过去 30 天)
显示 更早的评论
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'
0 个评论
采纳的回答
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)
0 个评论
更多回答(1 个)
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');
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!