MATLAB: Matrix manipulation

matrix manipulation

Hi, I've an ASCII file like this
450 1 2 3 4 5
6 7 8 9 10 11
12 13
451 1 2 3 4 5
6 7 8 9 10 11
12 13
452 1 2 3 4 5
6 7 8 9 10 11
12 13
...
and I would modify it to obtain a file like this
450 1 2 3 4 5 6 7 8 9 10 11 12 13
451 1 2 3 4 5 6 7 8 9 10 11 12 13
452 1 2 3 4 5 6 7 8 9 10 11 12 13
Any suggestions? Thanks Gianluca

Best Answer

f = fopen('test.txt');
c = textscan(f,'%f');
fclose(f);
out = reshape(c{:},[],3)'