问题
I have a set of x,y and z data (each is a 3000 by 1 matrix) and I would like to interpolate this data to have a set of values for the z height at evenly spaced x and y values. I assume I need to mesh grid the x and y data sets, but I don't know how to interpolate for the z data. The data points are the unique vertices taken from an STL file, and so I'm looking to smooth out the resulting surface.
Any help much appreciated ,
Tom.
回答1:
you have the matlab function interp2
then your code will be zi = interp2(x,y,z,xi,yi);
you can generate evenly spaced xi and yi using mesh grid
xi and yi will be the value of x and y at which you will make the interpolation, they are on a square form. E.g., if you want to interpolate at xi = 1 2 3 and yi = 4 5, then
xi will look like [1 2 3; 1 2 3]
and yi, [4 4 4; 5 5 5]
hope it helps!
来源:https://stackoverflow.com/questions/25647050/matlab-3d-data-interpolation