interpn vs griddata: how are results different?

Starting off from here:
A=data;
[X,Y,Z]=ndgrid(1:61,1:73,1:61);
x2=linspace(1, 61, 31);
y2=linspace(1, 73, 37);
z2=linspace(1, 61, 31);
[X2 Y2 Z2]=ndgrid(x2, y2, z2);
How are these variables below different? The correlation between data1 and data2 is r=.97.
data1=interpn(X2,Y2,Z2, A, X, Y, Z, 'linear');
data2=griddata(X2,Y2,Z2,A,X,Y,Z,'linear');
Thank you!

Respuestas (1)

Bruno Luong
Bruno Luong el 10 de Ag. de 2020

0 votos

Mathematical, in short the difference is
  • INTERPN uses tensorial linear function on nd-hypercube that enclose the query point.
  • GRIDDATA uses linear function on nd-simplex the query point

3 comentarios

Tahariet Sharon
Tahariet Sharon el 11 de Ag. de 2020
Thanks. Practically, what would be the difference?
Bruno Luong
Bruno Luong el 11 de Ag. de 2020
Editada: Bruno Luong el 11 de Ag. de 2020
INTERPN is faster and provides interpolation result more smooth (C1-discontinuouson smaller set) and better symmetric (invariant if you exchange coordinates) than GRIDDATA. If you have initial point on grid use INTERPN.
Use GRIDDATA only when you can't use the other (scattered data).
Tahariet Sharon
Tahariet Sharon el 11 de Ag. de 2020
Thank you!

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 10 de Ag. de 2020

Comentada:

el 11 de Ag. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by