www.gusucode.com > signal 案例源码程序 matlab代码 > signal/WelchEstimateUsingSpecifiedSegmentLengthExample.m
%% Welch Estimate Using Specified Segment Length % Obtain the Welch PSD estimate of an input signal consisting of a % discrete-time sinusoid with an angular frequency of $\pi/4$ rad/sample with % additive $N(0,1)$ white noise. % Copyright 2015 The MathWorks, Inc. %% % Create a sine wave with an angular frequency of $\pi/4$ rad/sample with % additive $N(0,1)$ white noise. Reset the random number generator for % reproducible results. The signal is 320 samples in length. rng default n = 0:319; x = cos(pi/4*n)+randn(size(n)); %% % Obtain the Welch PSD estimate dividing the signal into segments 100 % samples in length. The signal segments are multiplied by a Hamming window % 100 samples in length. The number of overlapped samples is 25. The DFT % length is 256 points, yielding a frequency resolution of $2\pi/256$ % rad/sample. Because the signal is real-valued, the PSD estimate is % one-sided and there are 256/2+1 points. segmentLength = 100; noverlap = 25; pxx = pwelch(x,segmentLength,noverlap); plot(10*log10(pxx))