了解这个函数,先看看这个基础知识:【 MATLAB 】Rational Transfer Function(有理传递函数)

filter

1-D digital filter

Syntax

y = filter(b,a,x)

y = filter(b,a,x,zi)

y = filter(b,a,x,zi,dim)

[y,zf] = filter(___)

Description

y = filter(b,a,x) 使用由分子和分母系数 b 和 a 定义的有理传递函数对输入数据 x 进行滤波。

If a(1) is not equal to 1, then filter normalizes the filter coefficients by a(1). Therefore, a(1) must be nonzero.

  • If x is a vector, then filter returns the filtered data as a vector of the same size as x.

  • If x is a matrix, then filter acts along the first dimension and returns the filtered data for each column.

  • If x is a multidimensional array, then filter acts along the first array dimension whose size does not equal 1.


针对这条语法举个例子:

Moving-Average Filter

移动平均滤波器是用于平滑噪声数据的常用方法。 此示例使用过滤器函数计算沿数据向量的平均值。

Create a 1-by-100 row vector of sinusoidal data that is corrupted by random noise.

t = linspace(-pi,pi,100);
rng default  %initialize random number generator
x = sin(t) + 0.25*rand(size(t));

A moving-average filter slides a window of length windowSize along the data, computing averages of the data contained in each window. The following difference equation defines a moving-average filter of a vector :

For a window size of 5, compute the numerator and denominator coefficients for the rational transfer function.

对于窗口大小为5,计算有理传递函数的分子和分母系数。

windowSize = 5;
b = (1/windowSize)*ones(1,windowSize);
a = 1;

Find the moving average of the data and plot it against the original data.

找到数据的移动平均值并根据原始数据绘制它。

y = filter(b,a,x);plot(t,x)
hold on
plot(t,y)
legend('Input Data','Filtered Data')


y = filter(b,a,x,zi) uses initial conditions zi for the filter delays. The length of zi must equal max(length(a),length(b))-1.

举例说明:

Filter Data in Sections

Use initial and final conditions for filter delays to filter data in sections, especially if memory limitations are a consideration.

Generate a large random data sequence and split it into two segments, x1 and x2.

x = randn(10000,1);x1 = x(1:5000);
x2 = x(5001:end);

The whole sequence, x, is the vertical concatenation of x1 and x2.

Define the numerator and denominator coefficients for the rational transfer function,

b = [2,3];
a = [1,0.2];

Filter the subsequences x1 and x2 one at a time. Output the final conditions from filtering x1 to store the internal status of the filter at the end of the first segment.

[y1,zf] = filter(b,a,x1);

Use the final conditions from filtering x1 as initial conditions to filter the second segment, x2.

y2 = filter(b,a,x2,zf);

y1 is the filtered data from x1, and y2 is the filtered data from x2. The entire filtered sequence is the vertical concatenation of y1 and y2.

Filter the entire sequence simultaneously for comparison.

y = filter(b,a,x);isequal(y,[y1;y2])
ans = logical1

y = filter(b,a,x,zi,dim) acts along dimension dim. For example, if x is a matrix, then filter(b,a,x,zi,2) returns the filtered data for each row.

举例:

This example filters a matrix of data with the following rational transfer function.

Create a 2-by-15 matrix of random input data.

rng default  %initialize random number generator
x = rand(2,15);

Define the numerator and denominator coefficients for the rational transfer function.

b = 1;
a = [1 -0.2];

Apply the transfer function along the second dimension of x and return the 1-D digital filter of each row. Plot the first row of original data against the filtered data.

y = filter(b,a,x,[],2);t = 0:length(x)-1;  %index vectorplot(t,x(1,:))
hold on
plot(t,y(1,:))
legend('Input Data','Filtered Data')
title('First Row')

Plot the second row of input data against the filtered data.

figure
plot(t,x(2,:))
hold on
plot(t,y(2,:))
legend('Input Data','Filtered Data')
title('Second Row')


[y,zf] = filter(___) also returns the final conditions zf of the filter delays, using any of the previous syntaxes.

这个形式的例子同:

y = filter(b,a,x,zi)


Output Arguments

y — Filtered data
vector | matrix | multidimensional array

Filtered data, returned as a vector, matrix, or multidimensional array of the same size as the input data, x.

If x is of type single, then filter natively computes in single precision, and y is also of type single. Otherwise, y is returned as type double.

Data Types: double | single

zf — Final conditions for filter delays
vector | matrix | multidimensional array

Final conditions for filter delays, returned as a vector, matrix, or multidimensional array.

  • If x is a vector, then zf is a column vector of length max(length(a),length(b))-1.

  • If x is a matrix or multidimensional array, then zf is an array of column vectors of length max(length(a),length(b))-1, such that the number of columns in zf is equivalent to the number of columns in x. For example, consider using filter along the second dimension (dim = 2) of a 3-by-4-by-5 array x. The array zf has size [max(length(a),length(b))-1]-by-3-by-5.

Data Types: double | single

【 MATLAB 】filter 函数介绍(一维数字滤波器)相关推荐

  1. 【 MATLAB 】filter 函数介绍 之 Filter Data in Sections

    [ MATLAB ]filter 函数介绍(一维数字滤波器) 在上篇博文中,里面有一个例子,就是过滤部分中的数据,这个部分中的数据的意思是如果有一个向量需要过滤,我们可以把它分为几段,然后分段过滤. ...

  2. MATLAB filter函数解析

    现在正在学习MATLAB信号处理方面的应用,程序中遇到filter函数,从网上查阅资料,我能找到的资料感觉写的也是模棱两可,不易使人明白,所以就花了一下午的时间好好研究了下,终于知道这个函数的使用方法 ...

  3. matlab filter 函数,C++ 实现matlab filter()函数

    (C++ 实现matlab filter()函数) C++ 实现matlab filter()函数 笔者在做信号处理的过程中,用到了一个带通滤波器,通过matlab计算设计好参数之后,直接调用filt ...

  4. lc filter在matlab哪,基于python实现matlab filter函数过程详解

    matlab中的filter函数: y = filter(b,a,x) python实现matlab中的filter函数 def filter_matlab(b,a,x): y = [] y.appe ...

  5. Matlab——filter函数和butter函数

    参考链接:http://www.ilovematlab.cn/thread-57684-1-1.html butter函数是求Butterworth数字滤波器的系数,在求出系数后对信号进行滤波时用fi ...

  6. matlab filter函数原理,基于python实现matlab filter函数过程详解

    matlab中的filter函数: y = filter(b,a,x) python实现matlab中的filter函数 def filter_matlab(b,a,x): y = [] y.appe ...

  7. matlab filter 函数 C语言实现

    C语言实现: #include <stdio.h> #include <math.h> #include <memory.h> #include <stdli ...

  8. 【 MATLAB 】impz函数介绍(数字滤波器的脉冲响应)

    这篇博文将MATLAB 帮助文档上的内容简单的贴上,便于我写其他博文引用,以及查看使用. impz Impulse response of digital filter Syntax [h,t] =  ...

  9. matlab滤波器脉冲响应,【 MATLAB 】impz函数介绍(数字滤波器的脉冲响应)

    这篇博文将MATLAB 帮助文档上的内容简单的贴上,便于我写其他博文引用,以及查看使用. impz Impulse response of digital filter Syntax [h,t] =  ...

最新文章

  1. php cookie使用实例h5,html5实现数据存储实例代码
  2. 基于深度神经网络的风电场超短期功率预测系统【数据故事计划最佳学术奖】...
  3. CCF-CSP 201703-2 试题名称: 学生排队(满分代码)
  4. 蚂蚁金服成立科学智囊团,机器学习之父Michael I.Jordan担任主席
  5. 【Socket网络编程】16.UDP 循环读取recvfrom() 与 循环发送 sendto()
  6. 【学习笔记】月末操作-GR/IR重组
  7. 怎么将SAP数据传输到其他系统(Transferring Data from SAP to Other Systems)
  8. 【2022年蓝桥杯】蓝桥杯第一次海选考试题(5题考试大二)
  9. 基于TCP和多线程实现无线鼠标键盘-GestureDetector
  10. TIM怎么更新版本 TIM检查更新版本教程
  11. RIP 图形、图像解析器
  12. 获取对象的key_玩转 SpringBoot2.x 之缓存对象
  13. delphi android路径 TPath 文件路径,文件管理
  14. MVC四大筛选器—ActionFilterResultedFilter
  15. .NET报表控件TeeChart使用教程:构建图表
  16. 【整理】system\app中的APK一览
  17. YouTube双字幕显示
  18. CSS3:颜色渐变和重复性渐变
  19. 高德地图定位,搜索,导航功能
  20. golang 修改全局默认时区的方法

热门文章

  1. HP一年升两年保修实例!(附图片)
  2. matlab求解集合覆盖问题,贪心算法实践之集合覆盖问题
  3. php 安装rabbitmq拓展_【RabbitMQ】——centos7安装rabbitmq教程 以及 PHP开启rabbitmq扩展...
  4. ajax 提交订单,php-在Woocommerce 3中通过ajax提交并在结帐时创建订单
  5. 异形隔离java剧情_异形隔离攻略 系统上手教程 全剧情流程图文攻略(41)
  6. 摘要注释_《间架结构摘要九十二法》高清图片+注释 爱书法的朋友值得收藏
  7. linux系统软件包分类,Linux软件包管理和编译安装
  8. java受保护的数据与_Javascript类定义语法,私有成员、受保护成员、静态成员等介绍...
  9. android app功能 配置,配置安装时分发  |  Android 开发者  |  Android Developers
  10. java gpg_gpg的使用