Scattered interpolation with weight factors
17 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Unai San Miguel
on 22 Nov 2019
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');
0 Comments
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!