title: How to redirect Matlab output of a command to a file?
body: <p>I want to redirect or copy the output of a Matlab command to a file. How can I do that?</p>
  
  <p>In my case, I have two large structs that I want to compare using the UNIX tool <code>diff</code>.</p>
  
  <p>Example: I can do this in Matlab:</p>
  
  <pre><code>&gt;&gt; s1
  
  s1 = 
  
        a: 32
      abc: 'example'
  
  &gt;&gt; 
  </code></pre>
  
  <p>and want a file containing approx:</p>
  
  <pre><code>s1 = 
  
        a: 32
      abc: 'example'
  </code></pre>
  
  <p>These solutions are not viable:</p>
  
  <ul>
  <li>Copy-pase: can't automate (comfortably).</li>
  <li><code>save -ascii</code>: does not work with structs.</li>
  </ul>