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
MATLAB实现最优低通滤波器的函数的更多相关文章
- [转]matlab语言中的assert断言函数
MATLAB语言没有系统的断言函数,但有错误报告函数 error 和 warning.由于要求对参数的保护,需要对输入参数或处理过程中的一些状态进行判断,判断程序能否/是否需要继续执行.在matlab ...
- matlab的滤波器仿真——低通滤波器与插值滤波器
项目里面有用到插值滤波器的场合,用matlab做了前期的滤波器性能仿真,产生的滤波器系数保存下来输入到FPGA IP中使用即可. 下面是仿真的代码 % clear all close all Nx = ...
- Matlab(3) -- 编写M文件(函数)
转自:http://blog.csdn.net/misskissc/article/details/8178089 matlab的命令编辑窗口(Command Window)界面主要是用来调用系统命令 ...
- MATLAB中提高fwrite和fprintf函数的I/O性能
提高fwrite和fprintf函数的I/O性能 http://www.matlabsky.com/thread-34861-1-1.html 今天我们将讨论下著名的fwrite(fprint ...
- MATLAB中导入数据:importdata函数
用load函数导入mat文件大家都会.可是今天我拿到一个数据,文件后缀名竟然是'.data'.该怎么读呢? 我仅仅好用matlab界面Workspace区域的"import data&quo ...
- matlab初学者_脚本文件调用函数文件
问题: matlab里面有两种文件,一种是脚本文件,一种是函数文件,为了模块化程序,我们需要把专门的功能写成一个函数封装到某个函数文件里面. 那么来看如何在脚本文件里调用函数文件中的函数. 注意点: ...
- Matlab入门学习(矩阵、函数、绘图的基本使用)
一.矩阵 1.定义和简单使用(一般的编程语言,数组下标都是从0开始的,但是MATLAB是从1开始的) >> a=[ ; ; ] a = >> b=[ ; ; ]; >&g ...
- matlab调用规则变量名eval函数
eval 函数运用!! 经常会遇到matlab里面有些变量命名其实有一样的规律,,但是不像矩阵这些是可以通过循环来获取的,这个时候就可以利用eval语句了: 首先,假设现在有10个名称类似的变量, ...
- Matlab中常见的神经网络训练函数和学习函数
一.训练函数 1.traingd Name:Gradient descent backpropagation (梯度下降反向传播算法 ) Description:triangd is a networ ...
随机推荐
- 不定宽高的DIV,垂直水平居中
1.怎么让一个不定宽高的DIV,垂直水平居中? 答:1)使用CSS方法. 父盒子设置: display:table-cell; text-align:center; vertical-align:mi ...
- python限制函数执行时间
from:https://stackoverflow.com/questions/366682/how-to-limit-execution-time-of-a-function-call-in-py ...
- 页面中 json 格式显示 数据
在页面中,有时候我们需要的不仅仅是将数据显示出来,而且要以以 json 的格式显示数据,如显示接口的时候 我们需要如下显示 这个时候,主要用到了 <pre> 标签 $.get(" ...
- 吴裕雄 数据挖掘与分析案例实战(4)——python数据处理工具:Pandas
# 导入模块import pandas as pdimport numpy as np # 构造序列gdp1 = pd.Series([2.8,3.01,8.99,8.59,5.18])print(g ...
- SQL 数据库主键 ,外键
主键 数据库主键是指表中一个列或列的组合,其值能唯一地标识表中的每一行.这样的一列或多列称为表的主键,通过它可强制表的实体完整性.当创建或更改表时可通过定义 PRIMARY KEY约束来创建主键.一个 ...
- centos7部署cacti
一.centos部署cacti 1. 关闭selinux. 2.fabric一键部署lamp 3. 设置mysql密码123456 1 mysql_secure_installation 4. 安装s ...
- 第八章 高级搜索树 (b1)B-树:动机
- spine
spine 英 [spʌɪn] 美 [spaɪn] n.脊柱;[动,植] 棘,刺(如刺猬和海胆的刺);鱼鳍的刺;植物上的刺
- UVa 230 Borrowers(map和set)
I mean your borrowers of books - those mutilators of collections, spoilers of the symmetry of shelve ...
- 获取APP的启动图 -Launch Image
http://adad184.com/2015/10/15/tips-access-current-launch-image/