MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
Find points that have similar x and y coordinates using uniquetol with these options:


  • Specify ByRows as true, since the rows of A contain the point coordinates.

  • Specify OutputAllIndices as true to return the indices for all points that are
    within tolerance of each other.

  • Specify DataScale as [1 1 Inf] to use an absolute tolerance for the x and y
    coordinates, while ignoring the z-coordinate.


DS = [1 1 Inf];
[C,ia] = uniquetol(A, 0.3, 'ByRows', true, ...
'OutputAllIndices', true, 'DataScale', DS);

Average each group of points that are within tolerance (including the z-coordinates),
producing a reduced data set that still holds the general shape of the original data.

for k = 1:length(ia)
aveA(k,:) = mean(A(ia{k},:),1);
end

Plot the resulting averaged-out points on top of the original data.

hold on
plot3(aveA(:,1), aveA(:,2), aveA(:,3), '.r', 'MarkerSize', 15)

2 Program Components

Free download pdf