Group characters and form a matrix in Matlab

后端 未结 3 1343
太阳男子
太阳男子 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:15

    Another approach using regular expressions:

    str = 'abcdefghijklmnopqrstuvwxyz';
    str = regexprep(str, '(.{4})', '$1 ');
    str = regexprep(str, '(.{4} .{4}) ', '$1\n');
    

提交回复
热议问题