频率响应的意义
\[x(n) = sin(0.01\pi n) \\ H(z)=\frac{0.05+0.05z^{-1}}{1-0.9z^{-1}} \]n = 0.:199;%取两百个点
x = sin(0.01*pi*n); %2pi/T = omega = 0.01pi,故T=200(所以一个周期采样了200个点)
b = [0.05,0.05]; a = [1,-0.9]; %b是系统响应z变换的分子系数 a是分母系数
y = filter(b,a,x); %求解差分方程
figure(1);%第一个图像
subplot(2,1,1);ylabel('x');
stem(n,x);grid on;
subplot(2,1,2);ylabel('x')
stem(n,y);grid on;ylabel('y');
figure(2);
[Fh,w] = freqz(b,a); %求系统的频率响应
[Gd,w] = grpdelay(b,a); %grpdelay表示群延迟
subplot(311); %幅度响应
plot(w/pi,abs(Fh));ylabel('|H(w)|');grid on;
subplot(312); %相位响应
plot(w/pi,angle(Fh));ylabel('angle|H(w)|');grid on;
subplot(313);%群延迟
plot(w/pi,Gd);ylabel('grd|H(w)|');grid on;
3点均值滤波系统
\[h(n) = \frac{1}{3}[\delta(n)+\delta(n-1)+\delta(n-2)] \\ y(n)=x(n)*h(n)=\frac{1}{3}[x(n)+x(n-1)+x(n-2)] \]简单一阶滤波器的设计
\[H(z) = 0.05\frac{1+z^{-1}}{1-0.9z^{-1}} \]b = [0.05 0.05]; %构造系统函数
a = [1 -0.9];
n = [0:99];
N = 100;fs = 1000;
x = sin(2*pi*10*n/fs)+sin(2*pi*250*n/fs); %构造两个频率成分 一个10Hz,一个250Hz,采样频率fs = 1000Hz
y = filter(b,a,x); %求系统输出
figure(1) %先画好画板
zplane(b,a);%画零极点图
figure(2)
subplot(211);plot(n,x);%画输入
subplot(212);plot(n,y);%画输出
figure(3)
Fx = fft(x);%画输入x(n)的频谱
subplot(311);
plot(n*fs/N,abs(Fx)/max(abs(Fx)));%Fx的频谱
[Hh,wh] = freqz(b,a,'whole');%画系统h(n)的频谱
subplot(312);plot(wh/pi,abs(Hh));
Fy = fft(y);
subplot(313);%画输出的频谱
plot(n*fs/N,abs(Fy)/max(abs(Fy)));
零极点图:
输入输出时域:
输入输出频域:
标签:subplot,滤波器,频率响应,plot,dspLearning,0.05,abs,ylabel,pi From: https://www.cnblogs.com/lycheezhang/p/17804285.html