MATLAB实现最优低通滤波器的函数
MATLAB实现最优低通滤波器的函数
% Fs --Data rate
% Fpass --pass band
% Fstop --Cutoff frequencies
% Apass --Passband ripple
% Astop --Stopband ripple
% Q_Bit --Quantization bits
function coef = LowPassFir(Fs,Fpass,Fstop,Apass,Astop,Q_Bit)
dens = 20; % Density Factor
a = [1 0]; % Desired amplitudes
rp = Apass;
rs = Astop;
% Compute deviations
dev = [(10^(rp/20)-1)/(10^(rp/20)+1),10^(-rs/20)];
% Calculate the order from the parameters using FIRPMORD.
[N, Fo, Ao, W] = firpmord([Fpass, Fstop]/(Fs/2), a, dev);
% Calculate the coefficients using the FIRPM function.
coef = firpm(N, Fo, Ao, W, {dens});
coe = coef;
fft_coe = 20*log(abs(fft(coe,1024)))/log(10);
% x_f = [0:(Fs/length(fft_coe)):Fs/2];
% m = fft_coe(1:length(x_f));
% plot(x_f,m),grid
fft_shift_coe = fftshift(fft_coe);
x_f = [-Fs/2+(Fs/length(fft_shift_coe)):(Fs/length(fft_shift_coe)):Fs/2];
plot(x_f,fft_shift_coe);grid
HB
function Coef = LowPassHb(Fs,Fpass,Apass,n)
% -- Fs sample frequency
% -- Fpass
% -- Apass(dB)
% -- n stage of the half band fir
fp = Fpass*2/(Fs);
dev = [(10^(Apass/20)-1)/(10^(Apass/20)+1)];
% dev = Apass;
switch nargin
case 3
Coef = firhalfband('minorder',fp,dev);
case 4
Coef = firhalfband(n,fp);
otherwise
error('error');
end
Coef = Coef';
vpa(Coef,16);
fft_coe = 20*log(abs(fft(Coef,1024)))/log(10);
% x_f = [0:(Fs/length(fft_coe)):Fs/2];
% m = fft_coe(1:length(x_f));
% plot(x_f,m),grid
fft_shift_coe = fftshift(fft_coe);
x_f = [-Fs/2+(Fs/length(fft_shift_coe)):(Fs/length(fft_shift_coe)):Fs/2];
plot(x_f,fft_shift_coe);grid
最新文章
- css样式之border-radius
- Power Management开发的一般流程
- 2014 summer training总结篇
- 性能工具MiniProfiler在Asp.Net WebForm跟踪EntityFramework
- WPF MenuItem 四种角色分析
- 新浪微博客户端(22)-创建微博Cell
- maven,spring,mybatis集成错误
- 关于stringWithFormat: - 两段NSString如何合成一段
- SD卡初始化以及命令详解
- 软考 程序员 下午考题 c语言 笔记
- 【iOS】Swift ?和 !(详解)
- XSS绕过<;>;进行测试
- DAX/PowerBI系列 - 查询参数用法详解(Query Parameter)
- 关于laravel5 消息订阅/发布的理解初
- 最新的windows xp sp3序列号 xp序列号
- javascript 事件流的应用之 addEventListener
- 搭建ntp服务器
- 一个Java例子,解释清楚注解的作用
- HDU4745——Two Rabbits——2013 ACM/ICPC Asia Regional Hangzhou Online
- Loadrunner进行md5加密方法