I am new to Matlab and I have an issue where two counters in my code do not change value.
fid = fopen('results.txt', 'wt'); counter1 = 0; counter2 = 3; for i=1:size(res_t,1) counter1 = counter1 + 1; if(counter2 == 3) fprintf(fid, '%f ', res_t.time(:,:)); % first column i need the time
counter2 = 0; end fprintf(fid, '%f ', res_t.data(:,:)'); if(counter1 == 3) fprintf(fid, '\n'); %after it writes all 3 X,Y,Z i want to change line
counter1 = 0; end counter2 = counter2 + 1; end fclose (fid);}
When compiled, the values of counter1 & counter2 do not change, which means they never meet the If statement conditions. My output file is a file which contains: column1: time values, columns2 to 4: X, Y, Z coordinates respectively.
For example:
Time1 X1 Y1 Z1
Time2 X2 Y2 Z2
Thanks!
Best Answer