matlab数字信号与应用源代码5

源代码在线查看: 5-8.m

软件大小: 8 K
上传用户: zhou28
关键词: matlab 数字 信号与 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				%例程5-8  利用Bartlett法估计功率谱
				% e.g.5-8.m for example5-8;
				% to test function psd;
				 
				clear all;
				% Generate the signal with noise and display
				N=1024;
				n=0:1/(N-1):1;
				f1=0.1;
				f2=0.9;
				wn=randn(1,N);
				xn=sin(2*pi*f1*n)+2*cos(2*pi*f2*n)+wn;
				subplot(311);
				plot(n,xn); xlabel('n');
				title(' xn=sin(2*pi*f1*n)+2*cos(2*pi*f2*n)+wn');
				% Estimate the PSD
				window=boxcar(N/8);
				[Pxx,Pxxc,f]=psd(xn,1024,1000,window,0,0.9);
				 f=(0:length(Pxx)-1)/length(Pxx);
				plot_Pxx=10*log10(abs(Pxx));
				subplot(312);
				plot(f,plot_Pxx);
				grid on
				xlabel('Frequency'), 
				ylabel('Power Spectrum (dB)');
				%Estimate the PSD with 90% confidence interval
				subplot(313);
				plot(f,10*log10(Pxx-Pxxc(:,1)), f,10*log10(Pxx+Pxxc(:,1)));
				xlabel('Frequency(Hz)');
				ylabel('Power Spectrum(dB)');
				title('PSD with 90% confidence interval');
				grid;
							

相关资源