Matlab filter常用函数

Filtering and Analysis Functions

Filtering

Function Description

fftfilt


Filters a signal with a digitalFilter using an FFT-based overlap-add method


filter


Filters a signal using a digitalFilter


filtfilt


Performs zero-phase filtering of a signal with a digitalFilter

Filter Analysis

Function Description

double


Casts the coefficients of a digitalFilter to double precision


filt2block


Generates a Simulink? filter block corresponding to a digitalFilter


filtord


Returns the filter order of a digitalFilter


firtype


Returns the type (1, 2, 3, or 4) of an FIR digitalFilter


freqz


Returns or plots the frequency response of a digitalFilter


fvtool


Opens the Filter Visualization Tool and displays the magnitude response of a digitalFilter


grpdelay


Returns or plots the group delay response of a digitalFilter


impz


Returns or plots the impulse response of a digitalFilter


impzlength


Returns the length of the impulse response of a digitalFilter, whether actual (for FIR filters) or effective (for IIR filters)


info


Returns a character array with information about a digitalFilter


isallpass


Returns true if a digitalFilter is allpass


isdouble


Returns true if the coefficients of a digitalFilter are double precision


isfir


Returns true if a digitalFilter has a finite impulse response


islinphase


Returns true if a digitalFilter has linear phase


ismaxphase


Returns true if a digitalFilter is maximum phase


isminphase


Returns true if a digitalFilter is minimum phase


issingle


Returns true if the coefficients of a digitalFilter are single precision


isstable


Returns true if a digitalFilter is stable


phasedelay


Returns or plots the phase delay response of a digitalFilter


phasez


Returns or plots the (unwrapped) phase response of a digitalFilter


single


Casts the coefficients of a digitalFilter to single precision


ss


Returns the state-space representation of a digitalFilter


stepz


Returns or plots the step response of a digitalFilter


tf


Returns the transfer function representation of a digitalFilter


zerophase


Returns or plots the zero-phase response of a digitalFilter


zpk


Returns the zero-pole-gain representation of a digitalFilter


zplane


Displays the poles and zeros of the transfer function represented by a digitalFilter

1.zero,pole-->transfer function form

[b,a] = zp2tf(zer,pol,1);
fvtool(b,a)

2.transform function-->zero/polo

fvtool(b,a,‘Analysis‘,‘polezero‘)

zplane(b,a)

3.Z-transform frequency response of a digital filter.

[h,w] = freqz(b,a,p)

returns the p-point complex frequency response, H(ejω), of the digital filter.

For example, a ninth-order Butterworth lowpass filter with a cutoff frequency of 400 Hz, based on a 2000 Hz sampling frequency, is

[b,a] = butter(9,400/1000);

To calculate the 256-point complex frequency response for this filter, and plot the magnitude and phase with freqz, use

freqz(b,a,256,2000)

4.filter

Use filter in the form y = filter(d,x) to filter an input signal, x, with a digitalFilterd, and obtain output data, y.

5.designfilt(https://ww2.mathworks.cn/help/signal/ref/designfilt.html)

Use designfilt in the form d = designfilt(resp,Name,Value) to design a digital filter, d, with response type resp. Specify the filter further using a set of Name,Value pairs.

Type d.Coefficients to obtain the coefficients of a digitalFilterd. For IIR filters, the coefficients are expressed as second-order sections.

Lowpass IIR Filter

Design a lowpass IIR filter with order 8, passband frequency 35 kHz, and passband ripple 0.2 dB. Specify a sample rate of 200 kHz. Visualize the magnitude response of the filter. Use it to filter a 1000-sample random signal.

lpFilt = designfilt(‘lowpassiir‘,‘FilterOrder‘,8, ...
         ‘PassbandFrequency‘,35e3,‘PassbandRipple‘,0.2, ...
         ‘SampleRate‘,200e3);
fvtool(lpFilt)

dataIn = randn(1000,1);
dataOut = filter(lpFilt,dataIn);

Output the filter coefficients, expressed as second-order sections.

sos = lpFilt.Coefficients
sos = 4×6

    0.2666    0.5333    0.2666    1.0000   -0.8346    0.9073
    0.1943    0.3886    0.1943    1.0000   -0.9586    0.7403
    0.1012    0.2023    0.1012    1.0000   -1.1912    0.5983
    0.0318    0.0636    0.0318    1.0000   -1.3810    0.5090

Bandpass FIR Filter

Design a 20th-order bandpass FIR filter with lower cutoff frequency 500 Hz and higher cutoff frequency 560 Hz. The sample rate is 1500 Hz. Visualize the magnitude response of the filter. Use it to filter a random signal containing 1000 samples.

bpFilt = designfilt(‘bandpassfir‘,‘FilterOrder‘,20, ...
         ‘CutoffFrequency1‘,500,‘CutoffFrequency2‘,560, ...
         ‘SampleRate‘,1500);
fvtool(bpFilt)

dataIn = randn(1000,1);
dataOut = filter(bpFilt,dataIn);

Output the filter coefficients.

b = bpFilt.Coefficients
b = 1×21

   -0.0113    0.0067    0.0125   -0.0445    0.0504    0.0101   -0.1070    0.1407   -0.0464   -0.1127    0.1913   -0.1127   -0.0464    0.1407   -0.1070    0.0101    0.0504   -0.0445    0.0125    0.0067   -0.0113 ?

6.fvtool

fvtool(b,a)
fvtool(sos)
fvtool(d)
fvtool(b1,a1,b2,a2,...,bN,aN)
fvtool(sos1,sos2,...,sosN)
fvtool(Hd)
fvtool(Hd1,Hd2,...,HdN)
h = fvtool(...)

Use fvtool to visualize a digitalFilterd.

原文地址:https://www.cnblogs.com/fellow1988/p/9180818.html

时间: 2024-08-30 09:44:52

Matlab filter常用函数的相关文章

matlab 图像常用函数

Canny function [ canny ] = canny( rgb ) temp=rgb2gray(rgb); canny=edge(temp,'canny'); end 灰度 temp=rgb2gray(rgb); 播放视频 clear all source = VideoReader('d:\v\\bus\1.avi'); myObj = VideoWriter('bus1.avi'); open(myObj); c= source.numberOfFrames; for i=1:c

MATLAB中的常用函数

MATLAB中的常用函数 1. 特殊变量与常数 主题词 意义 主题词 意义 ans 计算结果的变量名 computer 确定运行的计算机 eps 浮点相对精度 Inf 无穷大 I 虚数单位 inputname 输入参数名 NaN 非数 nargin 输入参数个数 nargout 输出参数的数目 pi 圆周率 nargoutchk 有效的输出参数数目 realmax 最大正浮点数 realmin 最小正浮点数 varargin   实际输入的参量 varargout 实际返回的参量     2.

Matlab - 常用函数集锦

在使用matlab进行信号处理和图形绘制过程中,某些函数被频繁调用,所以有必要将这些常用函数进行总结归类. 滤波函数 低通滤波 function [filtered_signal,filtb,filta]=lopass_butterworth(inputsignal,cutoff_freq,Fs,order) % Low-pass Butterworth filter % [filtered_signal,filtb,filta] = lopass_butterworth(inputsignal

lambda函数,常用函数,内置函数(string,zip()map()filter())的用法

lambda函数胡使用#coding:utf-8g = lambda x,y:x*y/*必须亦g=*/print g(2,3)/*print必须有*/swtich函数使用 def jia(x,y):    return x+ydef jian(x,y):    return x-ydef cheng(x,y):    return x*ydef chu(x,y):    return x/yoperator = {"+":jia,"-":jian,"*&q

Matlab图像处理常用基本函数

之前用Matlab做图像处理工作时,用到什么函数就查什么函数,从没做过系统的总结,再做的时候又要去查,所以总结还是有必要的~ 为了方便,在此只列出函数名和基本用法,如不特别指出,不详细说明参数,辅助help和doc 争取持续更新~ ********************************正文分割线************************************* 图像读入 需求 函数 说明 从某一路径读入图片 f = imread(FILENAME) 默认为当前搜索路径包括当前路

PYTHON-常用的类型转换函数和序列常用函数有哪些?

一.类型转换函数 chr(i)chr()函数返回ASCII码对应的字符串.print chr(65) Aprint chr(66) Bprint chr(65)+chr(66) AB ord(x)ord()函数返回一个字符串参数的ASCII码或Unicode值.ord("a") 97ord(u"a") 97 hex(x)hex()函数可把整数转换成十六进制数.hex(16) '0x10'hex(123) '0x7b' oct(x)oct()函数可把给出的整数转换成八

matlab 的plot 函数

基本形式 >> y=[0 0.58 0.70 0.95 0.83 0.25]; >> plot(y) 生成的图形是以序号为横坐标.数组y的数值为纵坐标画出的折线. >> x=linspace(0,2*pi,30); % 生成一组线性等距的数值 >> y=sin(x); >> plot(x,y) 生成的图形是上30个点连成的光滑的正弦曲线. 多重线 在同一个画面上可以画许多条曲线,只需多给出几个数组,例如 >> x=0:pi/15:2*

我自己的Javascript 库,封装了一些常用函数 Kingwell.js

我自己的Javascript 库,封装了一些常用函数 Kingwell.js 博客分类: Javascript javascript 库javascript库 现在Javascript库海量,流行的也多,比如jQuery,YUI等,虽然功能强大,但也是不万能的,功能不可能涉及方方面面,自己写一个的JS库是对这些的补充,很多也比较实用,把应用到项目中中去也比较方面,这也是对工作的一些积累,也加深对知识的理解. 2012-6-20更新,添加设置Cookie,获取Cookie,删除Cookie方法.很

numpy函数库中一些常用函数的记录

numpy函数库中一些常用函数的记录 最近才开始接触python,python中为我们提供了大量的库,不太熟悉,因此在<机器学习实战>的学习中,对遇到的一些函数的用法进行记录. (1)mat( ) numpy函数库中存在两种不同的数据类型(矩阵matrix和数组array),都可以用于处理行列表示的数字元素.虽然他们看起来很相似,但是在这两个数据类型上执行相同的数学运算可以得到不同的结果,其中numpy函数库中matrix与MATLAB中matrices等价. 调用mat( )函数可以将数组转