title: Surf interpolated data in matlab
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2848015/how-do-i-make-a-surf-plot-in-matlab-with-irregularly-spaced-data">How do I make a surf plot in MATLAB with irregularly spaced data?</a>  </p>
  </blockquote>
  
  
  
  <p>I have such data:</p>
  
  <pre><code>data = [
  x1 y1 z1
  x2 y2 z2
  ...
  xn yn zn
  ];
  </code></pre>
  
  <p>I need to get surface of this data. Third row, z - will be the height of surface. But Xs and Ys are not monotonic continous data, so this doesn't work:</p>
  
  <pre><code>[X Y] = meshgrid(data(:,1), data(:,2));
  Z = interp2(data(:,1), data(:,2), data(:,3), X, Y);
  </code></pre>
  
  <p>because my data in first and second row is not monotonic.</p>
  
  <p><strong>Update:</strong></p>
  
  <p><a href="http://www.mathworks.com/help/matlab/ref/triscatteredinterp.html" rel="nofollow noreferrer">TriScatteredInterp</a> can do this.(Thanks @Rody Oldenhuis)</p>
  
  <pre><code>F = TriScatteredInterp(data(:,1), data(:,2), data(:,3))
  ti=1:10:600;
  [qx qy] = meshgrid(ti, ti);
  qz = F(qx, qy);
  mesh(qx, qy, qz);
  </code></pre>