MATLAB: How to compute the mean and median frequency of a power spectrum using the Signal Processing Toolbox

Signal Processing Toolbox

I would like to compute the following:
1. The mean frequency of a power spectrum, defined as the normalized,
one-sided, first order spectral moment.
2. The median frequency defined as the particular frequency that would divide the
power spectrum into two parts of equal area.

Best Answer

Since R2015a, you can use meanfreq and medfreq in the Signal Processing Toolbox to compute mean and median frequency of power spectrum. For previous releases, the ability to compute the mean frequency of a power spectrum is not available. To compute the median frequency, you may implement the following:
If you use spectrum objects, the PSD data object resulting from a PSD method has functions to compute average power on a given frequency interval.
You can use these functions to compute the average power over the entire Nyquist interval.
Then, you can reuse it to compute the average power from DC (frequency of zero) to a certain estimated frequency, and check if you receive half of the total power.
You may need to iterate over your estimated frequency to find the exact frequency at which you would encompass half the average power. For more information on spectrum objects, refer the following URL: