0

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.

tomlj
  • 21
  • 2
  • Thanks, Ive tried using interp3 and produced a the xi yi values using meshgrid (I think). Im now getting an error saying Error using griddedInterpolant The grid vectors are not strictly monotonic increasing. Some of the values in a single column are the same, but each row (the full x y z data point) is unique. – tomlj Sep 04 '14 at 09:51

1 Answers1

0

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!

Pieter V.
  • 134
  • 6