www.gusucode.com > signal 案例源码程序 matlab代码 > signal/MeanFrequencyOfBandlimitedSignalsExample.m

    %% Mean Frequency of Bandlimited Signals
% Generate a signal whose PSD resembles the frequency response of an
% 88th-order bandpass FIR filter with normalized cutoff frequencies
% $0.25\pi$ rad/sample and $0.45\pi$ rad/sample.

% Copyright 2015 The MathWorks, Inc.


%%

d = fir1(88,[0.25 0.45]);

%%
% Compute the mean frequency of the signal between $0.3\pi$
% rad/sample and $0.6\pi$ rad/sample. Plot the PSD and annotate the
% mean frequency and measurement interval.

meanfreq(d,[],[0.3 0.6]*pi);

%%
% Output the mean frequency and the band power of the measurement interval.
% Specifying a sample rate of $2\pi$ is equivalent to leaving the rate
% unset.

[mnf,power] = meanfreq(d,2*pi,[0.3 0.6]*pi);

fprintf('Mean = %.3f*pi, power = %.1f%% of total \n', ...
    mnf/pi,power/bandpower(d)*100)

%%
% Add a second channel with normalized cutoff frequencies $0.5\pi$
% rad/sample and $0.8\pi$ rad/sample and an amplitude that is one-tenth
% that of the first channel.

d = [d;fir1(88,[0.5 0.8])/10]';

%%
% Compute the mean frequency of the signal between $0.3\pi$ rad/sample and
% $0.9\pi$ rad/sample. Plot the PSD and annotate the mean frequency of each
% channel and the measurement interval.

meanfreq(d,[],[0.3 0.9]*pi);

%%
% Output the mean frequency of each channel. Divide by $\pi$.

mnf = meanfreq(d,[],[0.3 0.9]*pi)/pi