title: reading stdin containing newlines in matlab
body: <p><code>stdin</code> can be read in Matlab using the <code>input</code> function as demonstrated in <a href="https://stackoverflow.com/a/23876233/873757">this post</a>. For instance:</p>
  
  <pre><code>printf "1\t2\n" | matlab -nojvm -nodesktop -nosplash -r "str=input('','s')"
  </code></pre>
  
  <p>Trying to read data with multiple newline characters fails because the first one signals the end of the <code>input</code> command:</p>
  
  <pre><code>printf "1\t2\n3\t4\n" | matlab -nojvm -nodesktop -nosplash -r "str=input('','s')"
    str =  1    2
    &gt;&gt;     3    4
           |
    Error: Unexpected MATLAB expression.
  </code></pre>
  
  <p>I have tried other possibilities including <code>fscanf(0,...)</code>,  <code>fscanf('',...)</code>, <code>fopen(0,'r')</code>, and <code>fopen('','r')</code>, to no avail. I wish to read lines of tab-separated data piped from another process, ideally directly into a cell array, or into a string which I can then parse myself. I could of course loop over <code>input</code> until the end of the stream, but I am wondering whether there is not some way to gather all the input at once.</p>