Hello,
I am trying to read dispersion outputs from the GULP lattice dynamics program. The format of the output file is shown in the attached file. Basically, it has 3 header lines and then two columns of data then three header lines and two columns of data repeating roughly 300 times (depends of the simulation parameters). I want to efficiently read this output without testing every line. My current code shown below works fine but it takes 30 seconds for a small output file and I want to optimize how this data is read in preparation for much larger files. Any suggestions?
fid = fopen([file]);idx = 0;idx2 = 1;z = 0;ticwhile ~feof(fid) %Check every line in the file
dummy = fgetl(fid); test = dummy(1); if ~strcmp(test,'#') dummy2 = strsplit(dummy,' '); C(idx2,1) = str2double(cell2mat(dummy2(1,2))); C(idx2,2) = str2double(cell2mat(dummy2(1,3))); idx2 = idx2 + 1; else Header(idx+1,1) = {dummy}; idx = idx + 1; end endtoc
Best Answer