Hi I want to save for loop outputs in different columns of txt file. Below is an example
C{1}=[562556554552552552550550554554] C{2}=[554572572576576590584584596596] fileID=('ans.txt'); fid=fopen(fileID,'w'); for j=1:2 for i=1:9 H(i)=C{j}(i)+C{j}(i+1) fprintf(fid, '%f \n', H(i)); end end
Then I've got the .txt file written as
1118.000000 1110.000000 1106.000000 1104.000000 1104.000000 1102.000000 1100.000000 1104.000000 1108.000000 1126.000000 1144.000000 1148.000000 1152.000000 1166.000000 1174.000000 1168.000000 1180.000000 1192.000000
I want the output written in two separate columns (9 x 2). How can I do to get that format? Thank you.
Best Answer