From: Babak Taati on
> M = round((rand(10,2)-.5)*65536); % generate integer matrix M
> fid = fopen('test.txt','w');
> fprintf(fid,[repmat('%g ',1,size(I,2)),'\n'], M);
> fclose(fid);

typo:

size(I,2) --> size(M,2)

otherwise works well :)