Possible Duplicate:
How do I make a surf plot in MATLAB with irregularly spaced data?
I have such data:
data = [
x1 y1 z1
x2 y2 z2
...
xn yn zn
];
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:
[X Y] = meshgrid(data(:,1), data(:,2));
Z = interp2(data(:,1), data(:,2), data(:,3), X, Y);
because my data in first and second row is not monotonic.
Update:
TriScatteredInterp can do this.(Thanks @Rody Oldenhuis)
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);
I think you're looking for TriScatteredInterp. From the documentation:
F = TriScatteredInterp(X, V) creates an interpolant that fits a surface of the form V = F(X) to the scattered data in (X, V). X is a matrix of size mpts-by-ndim, where mpts is the number of points and ndim is the dimension of the space where the points reside (ndim is 2 or 3). The column vector V defines the values at X, where the length of V equals mpts.
F = TriScatteredInterp(X, Y, V) and F = TriScatteredInterp(X, Y, Z, V) allow the data point locations to be specified in alternative column vector format when working in 2-D and 3-D.