Problem 42818. center of mass
R is a given matrix with size [n,2]. R(i,:) is interpreted as the 2D-position of a mass point with mass i. Calculate the center of mass of all mass points proposed by R.
Solution Stats
Problem Comments
-
4 Comments
I agree with William. If I'm reading the problem correctly, then for the second test, there should be a mass of 1 at (0,0) and a mass of 2 at (1,1) which would put the center at (2/3,2/3).
The equation for center of mass is the sum of the mass*radius divided by the total mass, NOT the total distance (which is what seems to be the case for the test suite)
Hi Katherine and William,
thank you very much for your advice. When I generated the test suite I made a stupid mistake (I divided by n which is totally wrong!). Sorry for that. I hope that its correct now.
Solution Comments
Show commentsProblem Recent Solvers76
Suggested Problems
-
4416 Solvers
-
Create a cell array out of a struct
2085 Solvers
-
Project Euler: Problem 2, Sum of even Fibonacci
2505 Solvers
-
Generate N equally spaced intervals between -L and L
880 Solvers
-
Let's get back to school, and create multiplication tables
215 Solvers
More from this Author9
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!