Here is the equation:
$$C_i=\frac{\displaystyle \sum_{k=1}^{W_{f_L}}kX_i(k)}{\displaystyle\sum_{k=1}^{W_{f_L}}X_i(k)} $$
The MATLAB code for the equation is:
sum(m.*window) / sum(window);
Let's say length(window) = 882 that contains the first half (abs) of the magnitude spectrum, fs = 44100.
Now calculate m:
m = ( (fs/(2*window)) * [1:window] )';
The length(m) = 882 and increments in 25, which is the sample range (e.g. [25 50 75 100 ... 22050]).
I'm trying to determine a better insight in terms of what is happening when both terms are being divided. It is clear that each element of m is multiplying each element of window, but what is actually happening? The book I'm reading just states that the Spectral Centroid is the center of 'gravity' of the spectrum.
mvariable, which is used as a weight for each element inX? I'm just a bit confused with thekvariable that is in front of the fraction. Is this the mean operator? – user1574598 Mar 29 '17 at 17:15