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

最新文章

  1. css样式之border-radius
  2. Power Management开发的一般流程
  3. 2014 summer training总结篇
  4. 性能工具MiniProfiler在Asp.Net WebForm跟踪EntityFramework
  5. WPF MenuItem 四种角色分析
  6. 新浪微博客户端(22)-创建微博Cell
  7. maven,spring,mybatis集成错误
  8. 关于stringWithFormat: - 两段NSString如何合成一段
  9. SD卡初始化以及命令详解
  10. 软考 程序员 下午考题 c语言 笔记
  11. 【iOS】Swift ?和 !(详解)
  12. XSS绕过<>进行测试
  13. DAX/PowerBI系列 - 查询参数用法详解(Query Parameter)
  14. 关于laravel5 消息订阅/发布的理解初
  15. 最新的windows xp sp3序列号 xp序列号
  16. javascript 事件流的应用之 addEventListener
  17. 搭建ntp服务器
  18. 一个Java例子,解释清楚注解的作用
  19. HDU4745——Two Rabbits——2013 ACM/ICPC Asia Regional Hangzhou Online
  20. Loadrunner进行md5加密方法

热门文章

  1. 吴裕雄 数据挖掘与分析案例实战(8)——Logistic回归分类模型
  2. Ansiable Manage MySQL global variables
  3. testlink问题--linux环境下
  4. 第五章 二叉树(c)二叉树
  5. ubuntu连有线网 无法连接外网
  6. iOS - xcode - label 字体自动根据宽高 显示完全
  7. volatile是否就是原子性/线程同步的
  8. 绑定服务-----------binderService TimerTask的使用
  9. jquery-jsonp插件解决跨域问题
  10. ecplice中去掉提示信息的步骤