www.gusucode.com > signal 案例源码程序 matlab代码 > signal/PercentageOfTotalPowerInFrequencyIntervalExample.m
%% Percentage of Total Power in Frequency Interval % Determine the percentage of the total power in a specified frequency interval. % Copyright 2015 The MathWorks, Inc. %% % Create a signal consisting of a 100 Hz sine wave in additive _N_(0,1) % white Gaussian noise. The sampling frequency is 1 kHz. Determine the % percentage of the total power in the frequency interval between 50 Hz and % 150 Hz. Reset the random number generator for reproducible results. rng('default') t = 0:0.001:1-0.001; x = cos(2*pi*100*t)+randn(size(t)); pband = bandpower(x,1000,[50 150]); ptot = bandpower(x,1000,[0 500]); per_power = 100*(pband/ptot)