www.gusucode.com > signal 案例源码程序 matlab代码 > signal/UpperAndLower95ConfidenceBoundsExample.m
%% Upper and Lower 95%-Confidence Bounds % The following example illustrates the use of confidence bounds with the % periodogram. While not a necessary condition for statistical % significance, frequencies in the periodogram where the lower confidence % bound exceeds the upper confidence bound for surrounding PSD estimates % clearly indicate significant oscillations in the time series. % Copyright 2015 The MathWorks, Inc. %% % Create a signal consisting of the superposition of 100 Hz and 150 Hz sine % waves in additive white _N_(0,1) noise. The amplitude of the two sine % waves is 1. The sampling frequency is 1 kHz. fs = 1000; t = 0:0.001:1-0.001; x = cos(2*pi*100*t)+sin(2*pi*150*t)+randn(size(t)); %% % Obtain the periodogram with 95%-confidence bounds. Plot the periodogram % along with the confidence interval and zoom in on the frequency region of % interest near 100 and 150 Hz. [pxx,f,pxxc] = periodogram(x,rectwin(length(x)),length(x),fs,... 'ConfidenceLevel', 0.95); plot(f,10*log10(pxx)) hold on plot(f,10*log10(pxxc),'r-.') xlim([85 175]) xlabel('Hz') ylabel('dB') title('Periodogram with 95%-Confidence Bounds') %% % The lower confidence bound in the immediate vicinity of 100 and 150 Hz is % significantly above the upper confidence bound outside the vicinity of % 100 and 150 Hz.