psdavper.m

来自「<统计智能信号处理>一书的matlab源程序」· M 代码 · 共 56 行

M
56
字号
function [R,varx]=psdavper(x,L,NFFT)
%
% [R,r]=psdavper(x,L,NFFT) performs
% PSD estimation using periodogram averaging
% with 50% segment overlapping
% r=autocorrelation estimate
% R=psd estimate
% x=input signal
% L=segment duration
% NFFT= FFT size (N=2^k and >=2*L)
%
% Programmed by: Dimitris Manolakis, 10/4/93
%
%-----------------------------------------------------------
% Copyright 2000, by Dimitris G. Manolakis, Vinay K. Ingle,
% and Stephen M. Kogon.  For use with the book
% "Statistical and Adaptive Signal Processing"
% McGraw-Hill Higher Education.
%-----------------------------------------------------------



N=length(x);
K=fix((N-L/2)/(L/2)); % Number of segments
time=(1:L)';

N1=2^nextpow2(2*L);
if NFFT<N1
disp('NFFT is less than 2L')
break
else
end

R1=zeros(NFFT,1);
w=hanning(L);

for k=1:K
   %xw=w.*detrend(x(time));
	xw=w.*x(time); % HANNING WINDOW
	X=fft(xw,NFFT);
	R1=R1+X.*conj(X);
	time=time+L/2;
end

R=R1(1:NFFT/2+1);
KLU=K*sum(w.*w);
R=R/KLU;
%break
% Callibrate to deal with positive frequencies only

R(1:NFFT/2)=R(1:NFFT/2)+R(2:NFFT/2+1);
R(NFFT/2+1)=2*R(NFFT/2+1);
R=R/NFFT;

varx=sum(R(1:NFFT/2));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?