Problem 61118. Center-of-Mass Index of a Vector

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

50.0% Correct | 50.0% Incorrect
Last Solution submitted on Dec 08, 2025

Problem Comments

Solution Comments

Show comments

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!