I want to split a Nx2 matrix into k number of matrices, find the centroid of each matrix and then put the centroids into another matrix.
For example for A = 50×2 matrix and k = 10
The 10 smaller matrices will be 5×2 each.
The matrix containing the centroids of 10 matrices will be 10×2
[ Centroid of a Nx2 matix is a point equidistant from all points in the matrix when plotted. Each of the matrix rows are x&y axis values. For a collection of points x1,x2,x3,…..xn & y1,y2,y3,…..yn.
Centroid(x',y')
x' = (x1+x2+x3+……+xn) /n
y' = (y1+y2+y3+……+yn) /n ]
How to constuct this code?
Best Answer