matlab resp函数,Matlab filter常用函数

35562e0325d6129f3bd4cdd48ade7b6f.png

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)

9735b991d78179a85f243621dd2078bc.png

3c304a4cc53860dcaa3ed29a657a8684.png

4.filter

Use filter in the form y = filter(d,x) to filter an input signal, x, with a digitalFilter, d, 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 digitalFilter, d. 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)

abbe54c71c4a00b36354dac343333c3c.png

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)

5ed7524b13bdc6be99708591b19b09fb.png

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 digitalFilter, d.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值