interp2 による内挿と、gri​ddataにおける内​挿との結果が異なりま​す

10 visualizaciones (últimos 30 días)
Takafumi
Takafumi el 25 de Mayo de 2018
Respondida: Takafumi el 25 de Mayo de 2018
正しい動作でしょうか?

Respuesta aceptada

Takafumi
Takafumi el 25 de Mayo de 2018
補間アルゴリズムが異なるため、計算結果は異なります。
特に、griddata は、三角形分割に基づく内挿補間をしています。
サンプル例を示しています。 理解しやすい線形補間の例です。
rng(100)
[X,Y] = meshgrid(-3:3);
V = reshape(randperm(49),[7 7]);
[Xq,Yq] = meshgrid(-3:0.5:3);
Vqi = interp2(X,Y,V,Xq,Yq,'linear');
Vqg = griddata(X,Y,V,Xq,Yq,'linear');
figure
diffdata = Vqg - Vqi;
mesh(Xq,Yq,diffdata)
% 確かに下の例で、中央の数値が異なっています。
Vqi(1:3,1:3)
Vqg(1:3,1:3)
% interp2においては、メッシュの4頂点の平均
isequal((Vqi(1,1) + Vqi(3,1) + Vqi(1,3) + Vqi(3,3))/4,Vqi(2,2))
% griddataは、斜めに対角線を引くので、(3,1) と(1,3)と平均
isequal((Vqi(3,1) + Vqi(1,3))/2,Vqg(2,2))

Más respuestas (0)

Categorías

Más información sobre 内挿 en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!