Given a numeric vector x, treat each element x(i) as a mass located at index i.
Compute the center-of-mass index
idx = sum(i * abs(x(i))) / sum(abs(x(i)))
If all elements are zero, return NaN.

Solution Stats

2 Solutions

1 Solvers

Last Solution submitted on Dec 08, 2025

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers1

Suggested Problems

More from this Author4

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!