MATLAB: Centroid of two arrays

arraycentroid

Hi,
I have a code that computes the centroids of two arrays as:
for ij=1:size(v1,1)
cent(ij)=centroid(v2,v1(ij,:));
end
What is the physical meaning of doing this operation? The help of 'centroid' explains the calculation of centroids for polygon shapes and I can not understand how the data in the two arrays is affected by centroid through that. The attached .mat file contains the two variables v1 and v2

Best Answer

I agree that the documentation on describing the inputs could be more specific. Look at the examples in the documentation for centroid and it may fill in the gaps. Plotting the results may help to interpret the results, too.
ij = 1; % sample the first iteration
plot(v2, v1(ij,:), 'ko')
ps = polyshape(v2,v1(ij,:));
[xCnt, yCnt] = centroid(ps);
hold on
plot(xCnt, yCnt, 'rx', 'MarkerSize', 15)
% Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been
% modified to create a well-defined polyshape.
% > In polyshape/checkAndSimplify (line 517)
% In polyshape (line 175)