用matlab实现切比雪夫滤波器
时间: 2023-06-11 14:10:37 浏览: 168
切比雪夫滤波器是一种频率选择性滤波器,可用于滤除特定频率范围内的信号。在Matlab中,可以使用`cheby1`函数来实现切比雪夫滤波器设计。
以下是一个示例代码,演示如何使用`cheby1`函数来设计并应用一个10阶的切比雪夫I型低通滤波器,截止频率为1000 Hz,通带最大衰减为3 dB,阻带最小衰减为40 dB。
```
% 采样频率
Fs = 8000;
% 截止频率
fc = 1000;
% 通带最大衰减(dB)
Rp = 3;
% 阻带最小衰减(dB)
Rs = 40;
% 计算通带截止频率与阻带截止频率
Wp = fc/(Fs/2);
Ws = 1.2*Wp;
% 计算滤波器阶数
[n, Wn] = cheb1ord(Wp, Ws, Rp, Rs);
% 设计切比雪夫I型低通滤波器
[b, a] = cheby1(n, Rp, Wn);
% 生成输入信号
t = 0:1/Fs:1;
x = sin(2*pi*500*t) + sin(2*pi*2000*t) + sin(2*pi*4000*t);
% 应用滤波器
y = filter(b, a, x);
% 绘制原始信号与滤波后信号的时域波形
subplot(2,1,1);
plot(t, x);
title('原始信号');
xlabel('时间(秒)');
ylabel('幅值');
subplot(2,1,2);
plot(t, y);
title('滤波后信号');
xlabel('时间(秒)');
ylabel('幅值');
```
在上述代码中,`cheb1ord`函数用于计算滤波器的阶数和截止频率,`cheby1`函数用于设计滤波器的系数,`filter`函数用于应用滤波器。最后,使用`subplot`和`plot`函数绘制原始信号与滤波后信号的时域波形。
阅读全文
相关推荐















