;蒄xlabel('Frequency(Hz)');ylabel('NormalizedPSD(dB)'),gridon;膄holdon羁%%EstimatePSDusingBTmethod蒅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;%overlapnumberforeachsegment膈nfft=pow2(nextpow2(length(x)));%nfft-pointsFFTforeachsegment膇[Pxx,f]=pwelch(x,window,noverlap,nfft,Fs);%callpwelchfunction