Scattered interpolation with weight factors

조회 수: 17 (최근 30일)
Thijs van de Wiel
Thijs van de Wiel 2019년 9월 2일
답변: Unai San Miguel 2019년 11월 22일
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
Thijs van de Wiel 2019년 9월 2일
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