# how does griddata asses duplicates?

1 view (last 30 days)
Valeria Leto on 10 Feb 2022
Edited: Adam Danz on 11 Feb 2022
Hi! I would like to understand how griddata asses duplicate point. I opened the function and I found this section:
%Need x,y and z to be column vectors
sz = numel(x);
x = reshape(x,sz,1);
y = reshape(y,sz,1);
v = reshape(v,sz,1);
myepsx = eps(0.5 * (max(x) - min(x)))^(1/3);
myepsy = eps(0.5 * (max(y) - min(y)))^(1/3);
% look for x, y points that are indentical (within a tolerance)
% average out the values for these points
if isreal(v)
xyv = builtin('_mergesimpts', [y, x, v], [myepsy, myepsx, Inf], 'average');
x = xyv(:,2);
y = xyv(:,1);
v = xyv(:,3);
could somebody explain me
xyv = builtin('_mergesimpts', [y, x, v], [myepsy, myepsx, Inf], 'average');

Adam Danz on 10 Feb 2022
Edited: Adam Danz on 11 Feb 2022
That line calls Matlab's built-in static method or function matlab.internal.math.mergesimpts(). The comments describe what it's doing. It takes the x y v vectors and defines tolerance levels for each variable (myepsy, myepsx, Inf). The tolerance levels define which values are "identical" or "close enough to be identical". Identical values are then averaged to get rid of (near) duplicates.

### Community Treasure Hunt

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

Start Hunting!

Translated by