两个坐标向量和一个对称赋值向量插值的不对称结果
Unsymmetrical result for an interpolation of two coordinate vectors and one symmetrical assigned value vector
我有两个坐标向量 x 是 x 方向的向量,y 是 y 方向的向量,相应的 z 值向量称为 "z"。
我现在想将这个不均匀的数据插入到一个非常精细的均匀坐标网格中。
但不知何故,尽管实际 z 值是对称的,但结果并不对称:
See output。
有人如何解决这个简单的问题?
这是我的代码:
x = [0;0;0;0;0;50;50;50;50;50;95;95;95;95;95;100;100;100;100;100;150;150;150;150;150];
y = [0;250;500;750;1000;0;250;500;750;1000;0;250;500;750;1000;0;250;500;750;1000;0;250;500;750;1000];
XspanVector = 1:1:150;
YspanVector = 1:1:1000;
[xx,yy] = meshgrid(obsXspanVector,obsYspanVector);
z = [2000 3000 15165 3000 2000 2000 3000 35750519 3000 2000 2000 3000 113059 3000 2000 2000 3000 109117 3000 2000 2000 3000 36863 3000 2000];
% Interpolate to grid
zz = griddata(x,y,z',xx,yy,'linear');
% Plot
contourf(xx,yy,10.*log10(zz),'LineColor','none');
您似乎有一个规则的 [5 x 5]
网格,因此您需要使用 interp2
or griddedInterpolant
.
而不是 griddata
xi = reshape(xObsG,5,5);
yi = reshape(yObsG,5,5);
zi = reshape(obsMaxIntInterpFlyoverSum,5,5);
z = interp2(xi,yi,zi,xxObsG,yyObsG);
contourf(xxObsG,yyObsG,10.*log10(z),'LineColor','none');
我有两个坐标向量 x 是 x 方向的向量,y 是 y 方向的向量,相应的 z 值向量称为 "z"。 我现在想将这个不均匀的数据插入到一个非常精细的均匀坐标网格中。 但不知何故,尽管实际 z 值是对称的,但结果并不对称: See output。 有人如何解决这个简单的问题? 这是我的代码:
x = [0;0;0;0;0;50;50;50;50;50;95;95;95;95;95;100;100;100;100;100;150;150;150;150;150];
y = [0;250;500;750;1000;0;250;500;750;1000;0;250;500;750;1000;0;250;500;750;1000;0;250;500;750;1000];
XspanVector = 1:1:150;
YspanVector = 1:1:1000;
[xx,yy] = meshgrid(obsXspanVector,obsYspanVector);
z = [2000 3000 15165 3000 2000 2000 3000 35750519 3000 2000 2000 3000 113059 3000 2000 2000 3000 109117 3000 2000 2000 3000 36863 3000 2000];
% Interpolate to grid
zz = griddata(x,y,z',xx,yy,'linear');
% Plot
contourf(xx,yy,10.*log10(zz),'LineColor','none');
您似乎有一个规则的 [5 x 5]
网格,因此您需要使用 interp2
or griddedInterpolant
.
griddata
xi = reshape(xObsG,5,5);
yi = reshape(yObsG,5,5);
zi = reshape(obsMaxIntInterpFlyoverSum,5,5);
z = interp2(xi,yi,zi,xxObsG,yyObsG);
contourf(xxObsG,yyObsG,10.*log10(z),'LineColor','none');