Group characters and form a matrix in Matlab

后端 未结 3 1333
太阳男子
太阳男子 2021-01-27 12:02

I have 26 characters A to Z, I group 4 characters together and separate the following 4 characters by a space which is like this:

abcd efgh ijkl mnop qrst uvwx y         


        
3条回答
  •  囚心锁ツ
    2021-01-27 12:37

    Another method is to use regexp

    A='abcd efgh ijkl mnop qrst uvwx yz';
    A_splited=regexp(A, '\S\S\S\S\s\S\S\S\S', 'match')
    

    However, the last 'yz' will not appear in this case. So there will be a need to tweak using something like this.

    A_splited{1,end+1}=A(end-rem(length(A),10)+1:end)
    

提交回复
热议问题