fre_fir_win.m

来自「经典《信号与系统》教程的matlab例程,对深入理解信号与系统相关概念有很大帮助」· M 代码 · 共 38 行

M
38
字号
%==========================================================================
%  Name:fre_fir_win.m
%  The program compute the DTFT of discrete-time sequence x(n),
%  and plot the curves.
%==========================================================================
clear;close all;
t0=10;%input('Type in the time dely t0=');
n=-30:60;
hd=0.4*sin(0.4*pi*(n-t0+eps))./(0.4*pi*(n-t0+eps));%input('Type in the impulse response h(n)=');
Rt0=u(n)-u(n-2*t0-1);
h=hd.*Rt0;
%==================================================
% Compute the DTFT of hd(n)
%==================================================
W1=pi;                           
N=512;           
k=-N:N;                              
W=k*W1/(N);                            
H=h*exp(-j*n'*W);                  
phi=57.3*angle(H); 
%=================================================
subplot(221);stem(n,hd,'.');grid on;axis([min(n),max(n),1.1*min(hd),1.2*max(hd)])
title('The impulse response hd(n)');

subplot(223);
stem(n,h,'.');grid on;axis([min(n),max(n),1.1*min(h),1.2*max(h)])
xlabel('Time index n');title('The impulse response h(n)');

subplot(222);
plot(k/N,abs(H));grid on;axis([-1,1,0,1.2*max(abs(H))])
title('The magnitude response ');


subplot(224);
plot(k/N,phi,'r');grid on;
axis([-1,1,min(phi),max(phi)])
xlabel('Frequency (*pi)');title('The phase response ');

⌨️ 快捷键说明

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