1. 程式人生 > >【 MATLAB 】freqz 函式介紹(數字濾波器的頻率響應)

【 MATLAB 】freqz 函式介紹(數字濾波器的頻率響應)

freqz

Frequency response of digital filter

Syntax

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

[h,w] = freqz(d,n)

[h,w] = freqz(___,n,'whole')

freqz(___)

[h,f] = freqz(___,n,fs)

[h,f] = freqz(___,n,'whole',fs)

h = freqz(___,w)

h = freqz(___,f,fs)

[h,w] = freqz(sos,n)

Description

[h,w] = freqz(b,a,n) returns the n

-point frequency response vector, h, and the corresponding angular frequency vector, w, for the digital filter with numerator and denominator polynomial coefficients stored in b and a, respectively.

[h,w] = freqz(b,a,n)返回數字濾波器的n點頻率響應向量h和相應的角頻率向量w,其中分子和分母多項式係數分別儲存在b和a中。

[h,w] = freqz(___,n,'whole')

 returns the frequency response at n sample points around the entire unit circle.

[h,w] = freqz(___,n,'whole') 返回整個單位圓周圍的n個取樣點的頻率響應。

Frequency Response from Transfer Function


Compute and display the magnitude response of the third-order IIR lowpass filter described by the following transfer function:

Express the numerator and denominator as polynomial convolutions. Find the frequency response at 2001 points spanning the complete unit circle.
 

clc;clear;close all;

b0 = 0.05634;
b1 = [1 1];
b2 = [1 -1.0166 1];
a1 = [1 -0.683];
a2 = [1 -1.4461 0.7957];

b = b0*conv(b1,b2);
a = conv(a1,a2);

[h,w] = freqz(b,a,'whole',2001);

% Plot the magnitude response expressed in decibels.


plot(w/pi,20*log10(abs(h)))
ax = gca;
ax.YLim = [-100 20];
ax.XTick = 0:.5:2;
xlabel('Normalized Frequency (\times\pi rad/sample)')
ylabel('Magnitude (dB)')


[h,w] = freqz(d,n) returns the n-point complex frequency response for the digital filter, d.

Frequency Response of an FIR Bandpass Filter

Design an FIR bandpass filter with passband between 0.35\pi and  0.8\pirad/sample and 3 dB of ripple. The first stopband goes from  0 to 0.1\pi rad/sample and has an attenuation of 40 dB. The second stopband goes from 0.9\pi rad/sample to the Nyquist frequency and has an attenuation of 30 dB. Compute the frequency response. Plot its magnitude in both linear units and decibels. Highlight the passband.
sf1 = 0.1;
pf1 = 0.35;
pf2 = 0.8;
sf2 = 0.9;
pb = linspace(pf1,pf2,1e3)*pi;

bp = designfilt('bandpassfir', ...
    'StopbandAttenuation1',40, 'StopbandFrequency1',sf1,...
    'PassbandFrequency1',pf1,'PassbandRipple',3,'PassbandFrequency2',pf2, ...
    'StopbandFrequency2',sf2,'StopbandAttenuation2',30);

[h,w] = freqz(bp,1024);
hpb = freqz(bp,pb);

subplot(2,1,1)
plot(w/pi,abs(h),pb/pi,abs(hpb),'.-')
axis([0 1 -1 2])
legend('Response','Passband','Location','South')
ylabel('Magnitude')

subplot(2,1,2)
plot(w/pi,db(h),pb/pi,db(hpb),'.-')
axis([0 1 -60 10])
xlabel('Normalized Frequency (\times\pi rad/sample)')
ylabel('Magnitude (dB)')

freqz(___) with no output arguments plots the frequency response of the filter.

Frequency Response of an FIR filter


Design an FIR lowpass filter of order 80 using a Kaiser window with . Specify a normalized cutoff frequency of  rad/sample. Display the magnitude and phase responses of the filter.


b = fir1(80,0.5,kaiser(81,8));
freqz(b,1)

Design the same filter using designfilt. Display its magnitude and phase responses using fvtool.
d = designfilt('lowpassfir','FilterOrder',80, ...
               'CutoffFrequency',0.5,'Window',{'kaiser',8});
freqz(d)

Note:   If the input to freqz is single precision, the frequency response is calculated using single-precision arithmetic. The output, h, is single precision.

[h,w] = freqz(sos,n) returns the n-point complex frequency response corresponding to the second-order sections matrix, sos.

[h,f] = freqz(___,n,fs) returns the frequency response vector, h, and the corresponding physical frequency vector, f, for the digital filter with numerator and denominator polynomial coefficients stored in b and a, respectively, given the sample rate, fs.

[h,f] = freqz(___,n,'whole',fs) returns the frequency at n points ranging between 0 and fs.

h = freqz(___,w) returns the frequency response vector, h, at the normalized frequencies supplied in w.

h = freqz(___,f,fs) returns the frequency response vector, h, at the physical frequencies supplied in f.

相關推薦

MATLAB freqz 函式介紹數字濾波器頻率響應

freqz Frequency response of digital filter Syntax [h,w] = freqz(b,a,n) [h,w] = freqz(d,n) [h,w] = freqz(___,n,'whole') freqz(___) [

MATLAB impz函式介紹數字濾波器的脈衝響應

這篇博文將MATLAB 幫助文件上的內容簡單的貼上,便於我寫其他博文引用,以及檢視使用。 impz Impulse response of digital filter Syntax [h,t]

MATLAB prod 函式介紹Product of array elements

prod Product of array elements Syntax B = prod(A) B = prod(A,dim) B = prod(___,type) B = prod(___,nanflag) Description B = prod(A)

MATLAB filter 函式介紹一維數字濾波器

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

MATLAB any 函式介紹確定是否有任意陣列元素非零

any Determine if any array elements are nonzero(確定是否有任何陣列元素非零) Syntax B = any(A) B = any(A,dim)

MATLAB zplane 函式介紹離散時間系統的零極圖

zplane Zero-pole plot for discrete-time systems Syntax zplane(b,a) zplane(b,a), where b and a are

MATLAB conj 函式介紹複共軛

conj Complex conjugate Syntax ZC = conj(Z) Description ZC = conj(Z) returns the complex conjugat

函式和常用模組day04函式介紹

本節內容 1、函式介紹 2、函式定義 3、為什麼要使用函式 一、介紹   在我們以往的學習程式設計的過程當中,碰到的最多的兩張程式設計方式或者說程式設計方法:面向過程和麵向物件。其實不管是哪一種,其實都是程式設計的方法論而已。但是現在有一種更古老的程式設計方式:函數語言程式設計,以它的不儲存的狀態,

MATLAB poly 函式介紹

poly Polynomial with specified roots or characteristic polynomial Syntax p = poly(r) p = poly(A)

MATLAB mkpp 函式介紹

mkpp Make piecewise polynomial Syntax pp = mkpp(breaks,coefs) pp = mkpp(breaks,coefs,d) Descript

matlabfreqz函式的使用(一)

>> help freqz freqz - Frequency response of filter         濾波器的頻率響應     This MATLAB function returns the frequency response h and

MATLAB find 函式的使用線性索引

find 查詢非零元素的索引和值 Syntax k = find(X) k = find(X,n) k = find(X,n,direction) [row,col] = find(___) [row,col,v] = find(___) Descript

MATLAB nextpow2 函式用法之 Optimize FFT with Padding

您可以使用nextpow2來填充傳遞給fft的訊號。 這樣做可以在訊號長度不是2的精確冪次時加速FFT的計算。 Optimize FFT with Padding   下面這個例子展示了 使用填充優化FFT的案例,通過使用函式nextpow2完成: clc c

MATLAB sinc 函式簡介

為了內容的完整性,這裡簡單的介紹了sinc函式,這個函式的更多應用實在訊號處理中,其他方便不清楚,因此,先基本瞭解,之後關於取樣函式的重構等知識在相關學科中再瞭解吧。   這是一個最基本的例子,畫出來

MATLAB DFT性質討論線性、迴圈反轉、共軛與時序列的對稱性的MATLAB實現

分別討論: 一、線性 給出一個例子,給出x1和x2,x3 = 0.3*x1+0.8*x2; 之後我們求x3的DFT,和x1和x2的DFT的線性組合是否一致,即可驗證線性性質。 clc,cle

matlabmod函式和rem函式的區別

mod函式用於取模。語法形式為M = mod(X, Y)。舉例說明: mod(20, 3)ans = 2;  mod(20, -3)ans = -1; mod([1 : 5], 3)ans = 1 2 0 1 2;  mod(magic(3), 3)ans = 2 1

matlabround函式的用法

round函式用於舍入到最接近的整數。語法形式只有1種:Y = round(X),這裡的X可以是數,向量,矩陣,輸出對應。舉例:1、round(2.1) = 2; round(2.5) = 3; rou

matlab函式作圖函式 ezplot

ezplot適用條件 “ezplot”命令可以用於顯函式、隱函式和引數方程作圖。 不同函式的使用格式 顯函式y=f(x) , ezplot 函式的呼叫格式為 ezplot(f, [xmin,xmax]); 隱函式f(x,y)=0 , ezplot 函式的呼叫格式為 ezplot(f, [xmi

Matlabisa函式解析 型別判斷函式

K = isa(obj, 'class_name')  判斷obj是否為class_name型別。如果是,返回邏輯1(真);如果不是,返回邏輯0(假)。 參量obj是一個MATLAB物件或者Java物件。參量class_name是MATLAB(預定義的或使用者定義的)物件或Java物件。預定義的MATL

MATLAB 進一步瞭解 chirp未完

當我直接去看chirp的MATLAB幫助文件時,始終不得要領,查看了很多博文上的說法,也還是不懂,直到我去查看了維基百科,並總結了下面這篇博文後,反過來看chirp的MATLAB幫助文件,才覺得明朗了一些。 因此,推薦看看上篇這篇博文,先從基礎上了解下chirp訊號。