I have list of file like this.
trj.hst.00.+00
trj.hst.01.+00
trj.hst.02.+00
trj.hst.03.+00
…
So, I want to use while loop and The number of files is not fixed
I do not know whether to use some functions.
Are as follows: The code I wrote
c=0;while (?) file = sprintf('trj.hst.%02d.+00',c); fid = fopen(file); tline = fgetl(fid); while ischar(tline)matches = strfind(tline, '#'); num = length(matches); if num > 0 tline = fgetl(fid); else B_temp = tline; B = fscanf(fid, '%g %g %g %g %g %g %g %g', [8 inf]); tline = fgetl(fid); end end fclose(fid); B2 = str2num(B_temp);B = B'; res = [B2; B]; DATA(1,c).res = res;% DATA.res_tline = B_temp;
c=c+1;end
Thanks in advance.
Best Answer