I believe the test suite answers are computed incorrectly. At least, the center of mass ought to lie within the range of coordinates occupied by the masses!
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.
Select every other element of a vector
Generate N equally spaced intervals between -L and L
02 - Vector Variables 3
Recaman Sequence - II
house of cards
solid of revolution
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office