title: Faster print of a 3D matrix
body: <p>I have a 3D large Matrix, the first index (<code>x</code>) represents frequency and the second and third indexes (<code>y</code> and <code>z</code>) are the indexes of the data. I want to print the data for each index for all the frequencies, then print a <code>|</code> char and a new line char. I do this in the following way:</p>
  
  <pre><code>% S is a 3D matrix of size (x,y,z), where y=z and x&gt;&gt;y
  N=size(S,2);
  MM=real(S);
  for mi=1:N
      for mj=1:N
          fprintf(fid,"%.16g ",MM(:,mi,mj));
          fprintf(fid,"|\n");
      end
  end
  </code></pre>
  
  <p>But for large matrices this is very slow. Is there a way to speed up the process?</p>
  
  <p>This is done in octave, which means that a Matlab solution will work as well.</p>