griddata vs griddedinterpolant vs scatteredInterpolant for given data

80 views (last 30 days)
I wish to perform 2D interpolation of a data. The data is such that
1 1 7
2 3 9
3 5 8
4 6 4
implying that V(1,1)= 7, V(2,3) =9, V(3,5)= 8 and V(4,6) = 4. I wish to find the values of V(1,3), V(1,5), V(1,6), V(2,1), V(2,5) and so on (basically all V(i,j), i not equal to j).
Since interp2 requires meshgrid format, from my reading of documentation, i guess that interp2 might not be a suitable function to use. Is it correct?
What is difference between griddata, griddedinterpolant and scatteredInterpolant to use for interpolation of this data? Can i use all of them for interpolation of such data givn above, how do I determine which is the most suitable to use for the above data
At the link 2D interpolation of data - MATLAB Answers - MATLAB Central (, scatteredInterpolant is suggested for interpolation. What if i use griddata or griddedinterpolant. Can i use it, what will be the difference?

Accepted Answer

Walter Roberson
Walter Roberson on 2 Nov 2022
griddedInterpolant -- if you do not pass in vector x and vector v (1D case) -- if you have 2 or more dimensions -- then the input coordinates must be in full gridded form, not individual samples.
griddata -- always x, y, v (scattered 2d input coordinates plus corresponding outputs). 'nearest', 'linear', 'natural', 'cubic', or 'v4' available
scatteredInterpolant -- can be scattered x, y, v, or can be scattered x, y, z, v . 'nearest', 'linear', or 'natural' available.
griddata() internally calls scatteredInterpolant for 'nearest', 'linear', and 'natural' options -- which is not a documented point and so is hypothetically subject to change.
Bruno Luong
Bruno Luong on 2 Nov 2022
@Walter Roberson "griddata is always griddata(x, y, v, xq, yq, then options, and never supports griddata(x, y, z, v, xq, yq, zq"
Hmm... But The doc mentions

Sign in to comment.

More Answers (2)

Bruno Luong
Bruno Luong on 2 Nov 2022
Edited: Bruno Luong on 2 Nov 2022
gridded data interpolant (A set of points that are axis-aligned and ordered, generated by meshgrid/ndgrid on monotonic grid vectors ) are just like what required by interp2, so it's out since your data doesn't meet that requirement.
They are just different implementation, some of them perform interpolation in 2 steps for better workflow if needed.
  1 Comment
Bruno Luong
Bruno Luong on 2 Nov 2022
Edited: Bruno Luong on 2 Nov 2022
Recommendation for scattered data:
Use scatteredInterpolant is you need to interpolation of query points at various places for the same sample points
Use griddata if you use 'v4' method, which I find quite remarkable in some circumstance, and I regret it is not implemented in scatteredInterpolant. The 'v4' is initially developped for stalite data acquired on narow tracks on earth surface.

Sign in to comment.

Bjorn Gustavsson
Bjorn Gustavsson on 2 Nov 2022
griddedinterpolant expects points on a regular grid pretty much like interp2 - so that function seems unsuitable for your case. As to the difference between griddata and scatteredInterpolant the main difference as I understand it is that the latter gives you a function that you can effectively call multiple times and re-use the triangulation that both methods use to interpolate, while repeated calls to griddata on the same data-set will redo that triangulation again and again. In addition to the common interpolation methods griddata also gives you the option to use the legacy 'v4' interpolation-method (which if my memmory serves me OK was some kriging base/like method).
One point of concern for you is that the X-Y points are close to co-linear and their triangulation doesn't span much - therefore triangulation-based interpolation will be restricted to a very narrow triangular region - outside of that extrapolation will be used. And we all know the perils of extrapolation.


Find more on Interpolation in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by