title: How to efficiently read in hexadecimal double data from a file?
body: <p>The purpose is to losslessly save and exchange data from Matlab. For example, given a double array:</p>
  
  <pre><code>&gt;&gt; a
  a(:,:,1) =
      0.8147    0.1270    0.6324
      0.9058    0.9134    0.0975
  a(:,:,2) =
      0.2785    0.9575    0.1576
      0.5469    0.9649    0.9706
  </code></pre>
  
  <p>we can save the data as hexadecimal format into a file</p>
  
  <pre><code>fp = fopen('test.dat','w');
  fprintf(fp, '%bX  ',a);
  </code></pre>
  
  <p>and get</p>
  
  <pre><code>3FEA1237688ABA7B  3FECFC3F5F570C7D  3FC0411A9F807B7C  3FED3A6000E256BF  3FE43C49753B9024  3FB8F8687182D4C0  3FD1D2EA3181CE68  3FE1800DABF8B5E0  3FEEA3E55FFC605B  3FEEE05DEBDEEB6B  3FC42CAA5B9D0950  3FEF0F1897ECA804  
  </code></pre>
  
  <p>In turn, we need to read these data into Matlab correctly. However, there is no the corresponding "%bX" format in fscanf(). I have searched and could do it one-by-one:</p>
  
  <pre><code>for k = 1 : xx
      tmp = fscanf(fp,'%s  ',[1 1]); 
      b(k) = hex2num(tmp);
  end
  </code></pre>
  
  <p>Since it is not efficient especially for large data, how to read in these data into Matlab efficiently?</p>