filter2.m

来自「the programs are an introduction to DSP 」· M 代码 · 共 36 行

M
36
字号
function filter_demo2

den = input ('denominator coefficients = ');
% den: coefficients of the denominator polynomial

num = input ('numerator coefficients = ');
% num: coefficients of the numerator polynomial

p = roots (den) % p: poles
z = roots (num) % z: zeros
k = input ('filter gain =')

zplane (z,p)

pause
[num,den]=zp2tf(z,p,k)

n=0:100;
imp=zeros(101,1);
imp(1)=1; x=imp;

h=filter(num,den,x);
subplot, stem(n,h)
title('Impulse Response')
xlabel('index (n)'),ylabel('h(n)')

hold off
pause

[H,W]=freqz(num,den,512);
subplot(211), plot(W,abs(H))
xlabel('w (rad)'),ylabel('Magnitude Response')
subplot(212), plot(W,angle(H))
xlabel('w (rad)'),ylabel('Phase Response')

⌨️ 快捷键说明

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