Search code examples
matlabplot3dinterpolation

Matlab - Interpolation over a 3D surf with matrix, nonuniform, scattered data


I am currently trying to interpolate the following surface plot in order to add more point and make it more smooth:

hSurf = surf(X,Y,Z)

with X,Y and Z all being matrices of size nXm.

When looking for a solution, I have found the function griddata but I have found only a syntax with X,Y and Z as vectors. Therefore any attempts did not succeed!

Do you have an idea? Thx a lot!

Kooglof


Solution

  • Using griddata was the correct approach. First, define a regular grid using meshgrid, e.g.

    [x,y] = meshgrid(-0.2160:-0.0001:-0.2319,0.2161:0.0001:0.2319); % replace the values by meaningful borders
    

    and then map the nonregular grid X, Y to the regular grid

    z = griddata(X,Y,Z,x,y,'cubic')
    

    where 'cubic' can be replaced by the preffered method.