经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助

源代码在线查看: hamming.m

软件大小: 159 K
上传用户: hard
关键词: matlab 信号与系统 教程
下载地址: 免注册下载 普通下载 VIP

相关代码

				% Name:Hamming.m
				clear
				L=input('Type in the length N=');
				n=0:L-1;
				w=(0.54-0.46*cos(2*pi*n/(L-1))).*(u(n)-u(n-L));
				x=0.3*sin(0.3*pi*(n-ceil((L-1)/2)+eps))./(0.3*pi*(n-ceil((L-1)/2)+eps)).*w;
				%==========================================================================
				N=1024;
				H1=fft(w,N);
				H2=fliplr(H1);
				H=[H2(1:1023),H1];
				H=H/max(abs(H));
				F1=fft(x,N);
				F2=fliplr(F1);
				F=[F2(1:1023),F1];
				F=F/max(abs(F));           
				W=-2*pi+2*pi/N:2*pi/N:2*pi-2*pi/N;
				%=======================================================================
				figure(1)
				subplot(221);
				plot(W/pi,abs(F)),title('The magnitude response of FIR filter')
				axis([-1,1,0,max(abs(F))]);grid on
				%=========================================================
				subplot(222)
				plot(W/pi,abs(H));grid on
				axis([-1,1,0,max(abs(H))])
				title('The frequency response of the Hamming window'),
				%======================================================
				subplot(224)
				plot(W/pi,20*log10(abs(H)/abs(H1(1))));grid on
				axis([0,1,-100,0])
				title('The frequency response in dB'),
				xlabel('Frequency (*pi)')
				%======================================================
				subplot(223)
				plot(W/pi,20*log10(abs(F)));grid on
				axis([0,1,-100,0])
				title('The frequency response in dB'),
				xlabel('Frequency (*pi)')
				%======================================================
				figure(2)
				subplot(221)
				stem(n,w,'.');grid on
				title('The Hamming window')
				xlabel('Index n')
				axis([0,L-1,min(w),max(w)])
				%=================================================
				subplot(222)
				stem(n,x,'.');grid on
				title('The truncated impulse response')
				xlabel('Index n')
				axis([0,L-1,min(x),max(x)])
				%==================================================
							

相关资源