title: Matlab: Fast reading of file with many lines of (%d %d %ld)
body: <p>I am kind of frustrated with <code>fscanf</code> and its time-performance in reading a file with structured data. I want to read a .txt file, which has three entries per line: DOUBLE DOUBLE LONG-DOUBLE, and I only want to read the first N entries. Unfortunatly, <code>fscanf</code> is very slow. Do you know any faster method?</p>
  
  <p>Btw, I am aware of several topics on this topic here, for instance <a href="https://stackoverflow.com/questions/9440592/fastest-matlab-file-reading">this question</a>. However, the answer does not help in my case, as i'm already using <code>fscanf</code>.</p>
  
  <p>My code is:</p>
  
  <pre><code>    formatSpec='%d %d %ld'; % important: last one is long-double to support 64bit values!
      sizeA=[3 100000];
      file1=fopen('file1.txt','r');
          [content,cc]=fscanf(file1,formatSpec,sizeA);        
      fclose(file1);
  </code></pre>
  
  <p>Do you know any more clever idea to read N lines of a file with the given structure? Thanks!</p>
  
  <p><strong>Edit:</strong> The filecontent of <code>file1.txt</code> looks like this:</p>
  
  <pre><code>1  1 204378259709308
  0  1 204378259782523
  1  1 204378260105693
  3  1 204378260381676
  3  1 204378260854931
  1  1 204378261349990
  1  1 204378262189528
  0  1 204378263067715
  1  1 204378263301204
  1  1 204378263676471
  1  1 204378263771064
  1  1 204378264565420
  0  1 204378264608240
  0  1 204378264973698
  ...
  3  1 205260543966542
  </code></pre>
  
  <p>So basicly:
  A[space][space]B[space]C
  with A and B are [0,9] and C is a 64bit integer</p>