0

I am trying to read hundreds of .dat file by skipping header lines (I do not know how many of them I need to skip beforehand). Header lines very from 1 to 20 and have at beginning either or "$" oder "!". A sample data (left column - node, right column - microstructure) has always two columns and looks like the following:

!===
!Comment
$Material
    1 1.452E-001
    2 1.446E-001
    3 1.459E-001

I tried the following codeline, assuming I know beforehand that there 3 lines in header:

fid = fopen('Graphite_Node_Test.dat') ;
data = textscan(fid,'%f %f','HeaderLines',3) ;
fclose(fid);

This solution works if the number of header lines is known. How can I change the code so that it can read the .dat file without knowing the number of header lines beginning with either "$" or "!" sign?

ofey
  • 1
  • 4

0 Answers0