timatePSDusingBTmethod蚂window_a=rectwin(length(x));%windowfunctionfordatax(n)蝿蒅xn=x'.*window_a;膃Rx=xcorr(xn);%auto-correlationfunctionestimate蒀N=length(Rx);衿M=floor(N/4);%thelengthofsmoothwindow袆%M=100;蚁window_v=rectwin(M);%smoothwindowforBTmethod艿RxWin=Rx(1:M).*window_v;%smoothwindowmultiplyauto-correlationfunction罿Pw=abs(fft(RxWin,N));羃莃k=0:floor(N/2-1);螄figure;螄plot(k*Fs/N,10*log10(Pw(k+1)/max(Pw)),'r');肀title('BTMethodPSDEstimate');薇xlabel('Frequency(Hz)');ylabel('NormalizedPSD(dB)'),gridon;螇%%EstimatePSDusingWelchmethod袄window=32;%thelengthofeachsegment蒁noverlap=8;%overlapnumberforeachsegmentnfft=pow2(nextpow2(length(x)));%nfft-pointsFFTforeachsegment[Pxx,f]=pwelch(x,window,noverlap,nfft,Fs);%callpwelchfunctionfigure;plot(f,10*log10(Pxx/max(Pxx)),'g');title('PwelchMethodPSDEstimate');