title: How can I catch all warnings during a Simulink simulation?
body: <p>I want to catch all warnings issued during the simulation of a Matlab/Simulink model. The result of simulation should be an array of warnings, as there might be more than one warning. </p>
  
  <p>The ideal code would look something like this (except that catch does not work with warnings):</p>
  
  <pre><code>try
     sim('myModel');
  catch warnings
     for i=1:length(warnings)
        &lt;process each warning&gt;
     end
  end
  </code></pre>
  
  <p>Things I've tried already without success:</p>
  
  <ul>
  <li>Turning the warnings into exceptions won't help, as I will only get the first warning and not all of them.</li>
  <li>Overriding the built-in warning function with my own "@char\warnings.m" will only catch the warnings in my own script but not in the sim-function.</li>
  <li><code>lastwarn</code> will give me only the last warning message, not all of them.</li>
  </ul>
  
  <p>P.S.: I'm using Matlab 2010b on Windows.</p>