griddata vs griddedinterpolant vs scatteredInterpolant for given data
133 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
RJSB
el 2 de Nov. de 2022
Comentada: Bruno Luong
el 2 de Nov. de 2022
I wish to perform 2D interpolation of a data. The data is such that
X Y V
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 (mathworks.com), scatteredInterpolant is suggested for interpolation. What if i use griddata or griddedinterpolant. Can i use it, what will be the difference?
Respuesta aceptada
Walter Roberson
el 2 de Nov. de 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.
6 comentarios
Walter Roberson
el 2 de Nov. de 2022
Editada: Walter Roberson
el 2 de Nov. de 2022
griddata is always griddata(x, y, v, xq, yq, then options, and never supports griddata(x, y, z, v, xq, yq, zq
scatteredInterpolant supports (x, y, v, then options, or (x, y, z, v, then options, so building an interpolation object over 2d or over 3d, that you then invoke with the appropriate number of input parameters to get results. Besides splitting the creation of the object from the invocation for interpolation purposes, griddata simply does not support 3 independent coordinate dimensions but scatteredInterpolant does.
Bruno Luong
el 2 de Nov. de 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"
"Syntax
Más respuestas (2)
Bjorn Gustavsson
el 2 de Nov. de 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.
HTH
0 comentarios
Bruno Luong
el 2 de Nov. de 2022
Editada: Bruno Luong
el 2 de Nov. de 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 comentario
Bruno Luong
el 2 de Nov. de 2022
Editada: Bruno Luong
el 2 de Nov. de 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.
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!