title: How does Matlab calculate contour lines?
body: <p>What is the algorithm that Matlab uses to generate contour lines? In other words, how does it transform level data on a grid into a set of lines?</p>
  
  <p>What I would like is:</p>
  
  <ul>
  <li>the local criterion to obtain points that lie on the contour?</li>
  <li>the global procedure to capture <em>all</em> contour lines?</li>
  </ul>
  
  <p>I don't need detailed specifics about the underlying code, but the general principles would be helpful for me to interpret the output. I use <code>contour</code> (and derivatives) in my research, and want to get a sense of the numerical errors that are introduced in this step.</p>
  
  <p><em>It looks like a very simple question, but I couldn't find an explanation in Matlab's documentation, nor found anything on SO or elsewhere on the web. My apologies if it turns about to be easy to find after all.</em></p>