Scattered interpolation with weight factors

17 次查看(过去 30 天)
Dear reader,
I am trying to interpolate scatter data as an input for my model. The input data is from different measurements and I would like to weight these measurements differently in my interpolation. The first measurement for instance I trust more and I would like to weight these points higher to focus the fit on this measurement. I use scatteredInterpolant often to fit measurement data, however, I have no idea how to introduce weight factors to this. I have looked into replicating the measurement data by repmat, however, if the weight factors become large this method is not prefered.
Do you have some tips for this application?
Kind regards,
Thijs
  2 个评论
TADA
TADA 2019-9-2
what about averaging with weight factor, then interpolating?
Thijs van de Wiel
I am using scatter data, how would you advise to average this? The data is 3D. This would be an example of the code I made until now:
However, as already stated, by replicating the data set can get very large, therefore, I would prefer a weighting factor.
x1=rand(1,10);x2=x1;
y1=rand(1,10);y2=y1;
z1=rand(1,10);
z2=rand(1,10);
x=[x1,x2];
y=[y1,y2];
z=[z1,z2];
F1=scatteredInterpolant(x',y',z','linear','nearest');
F2=scatteredInterpolant([x1,x2,x2]',[y1,y2,y2]',[z1,z2,z2]','linear','nearest');
[X,Y]=meshgrid(0:0.1:1,0:0.1:1);
Z1 = F1(X,Y);
Z2 = F2(X,Y);
figure
scatter3(x1,y1,z1)
hold on
scatter3(x2,y2,z2)
surf(X,Y,Z1,'FaceAlpha',0.5,'FaceColor','b')
surf(X,Y,Z2,'FaceAlpha',0.5,'FaceColor','r')
legend('z1','z2','Z1','Z2')

请先登录,再进行评论。

回答(1 个)

Unai San Miguel
Unai San Miguel 2019-11-22
You could add some random points near the point you rely more on. Close enough to effect the interpolation and separated enough to avoid Matlab thinking they are the same point. For example (playwith scale and npoints)
% Points around [x1; y1; z1]
scale = 1e-2;
npoints = 100;
padd = randn([3, npoints]) * scale + [x1(1); y1(1); z1(1)];
figure(11)
clf
scatter3(x1, y1, z1, 'o')
hold on
scatter3(padd(1,:), padd(2,:),padd(3,:), 'k.')
G1 = scatteredInterpolant(x1.', y1.', z1.', 'linear', 'nearest');
G2 = scatteredInterpolant([x1, padd(1,:)].', [y1, padd(2,:)].', [z1, padd(3,:)].', 'linear', 'nearest');
hs1 = surf(X, Y, G1(X, Y), 'FaceAlpha', 0.5, 'FaceColor', 'r', 'EdgeColor', 'none');
hs2 = surf(X, Y, G2(X, Y), 'FaceAlpha', 0.5, 'FaceColor', 'b', 'EdgeColor', 'none');
untitled.png

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by