Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagenone
function [centerX, centerY] = centerOfMass2dcenterOfMass2D(matrix)
[rows, cols] = size(matrix);
for i = 1:rows
    yVec(i) = sum(matrix(i, :));
end
centerY = centerOfMass(yVec);
for i = 1:cols
    xVec(i) = sum(matrix(:, i));
end
centerX = centerOfMass(xVec);
end