title: Trapz giving weird results
body: <p>I'm having a weird result with Matlab's trapz function. I have two variables, zptest and omega, both of which are positive, 3000x2x1 arrays.</p>
  
  <p>When I plot zptest vs omega (plot(zptest(:,1,1),omega(:,1,1)) the curve is clearly positive and should give a positive result when integrating. This is not the case, however, as shown below:</p>
  
  <blockquote>
    <blockquote>
      <p>trapz(zptest(:,1,1),omega(:,1,1))</p>
    </blockquote>
  </blockquote>
  
  <p>ans =</p>
  
  <p>-0.049999940237341</p>
  
  <p>just to prove that both omega and zptest are positive:</p>
  
  <blockquote>
    <blockquote>
      <p>find(omega(:,1,1) &lt; 0)</p>
    </blockquote>
  </blockquote>
  
  <p>ans =</p>
  
  <p>Empty matrix: 0-by-1</p>
  
  <blockquote>
    <blockquote>
      <p>find(zptest(:,1,1) &lt; 0)</p>
    </blockquote>
  </blockquote>
  
  <p>ans =</p>
  
  <p>Empty matrix: 0-by-1</p>
  
  <p>I know I'm not giving any context to what I'm actually doing but this seems like a context independent problem. Does anyone have any idea what's going on?</p>