% Original code has been modifieddirMain ='D:\test\'; fid = fopen([dirMain,'test.txt'],'wt');% Create txt if the txt not existmatrix =round(rand(4,5) *100); [m, n] =size(matrix);fori=1: mforj=1: nifj== n fprintf(fid,'%4f\n', matrix(i,j));% \n: new lineels...