MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Average Similar Data Points Using a Tolerance


This example shows how to use uniquetol to find the average z-coordinate of 3-D points
that have similar (within tolerance) x and y coordinates.

Use random points picked from the peaks function in the domain [−3,3]×[−3,3] as
the data set. Add a small amount of noise to the data.

xy = rand(10000,2)*6-3;
z = peaks(xy(:,1),xy(:,2)) + 0.5-rand(10000,1);
A = [xy z];
plot3(A(:,1), A(:,2), A(:,3), '.')
view(-28,32)

Average Similar Data Points Using a Tolerance
Free download pdf