1
freqz
uses an FFT-basedalgorithm to calculate the Z-transform frequency response of a digitalfilter. Specifically, the statement
[h,w] = freqz(b,a,p)
returns the p-point complex frequency response, H(ejω),of the digital filter.
H(ejω)=b(1)+b(2)e−jω+...+b(n+1)e−jωna(1)+a(2)e−jω+...+a(m+1)e−jωm
In its simplest form, freqz
accepts the filtercoefficient vectors b
and a
,and an integer p
specifying the number of pointsat which to calculate the frequency response. freqz
returnsthe complex frequency response in vector h
, andthe actual frequency points in vector w
in rad/s.
[h,w]= freqz(b,a,n)
[h,w] = freqz(sos,n)
[h,w] = freqz(d,n)
[h,w]= freqz(___,n,'whole')
[h,f]= freqz(___,n,fs)
[h,f]= freqz(___,n,'whole',fs)
h = freqz(___,w)
h = freqz(___,f,fs)
freqz(___)
example
[
returnsthe h
,w
]= freqz(b,a
,n
)n
-point frequency response vector, h
, and the corresponding angularfrequency vector, w
, forthe digital filter with numerator and denominator polynomial coefficientsstored in b
and a
, respectively.
example
[
returnsthe h
,w
] = freqz(sos
,n
)n
-point complex frequency response correspondingto the second-order sections matrix, sos
.
example
[
returnsthe h
,w
] = freqz(d
,n
)n
-point complex frequency response for thedigital filter, d
.
[
returnsthe frequency response at h
,w
]= freqz(___,n
,'whole')n
sample points aroundthe entire unit circle.
[
returnsthe frequency response vector, h
,f
]= freqz(___,n
,fs
)h
,and the corresponding physical frequency vector, f
, for the digital filter with numeratorand denominator polynomial coefficients stored in b
and a
,respectively, given the sampling frequency, fs
.
[
returnsthe frequency at h
,f
]= freqz(___,n
,'whole',fs
)n
points ranging between 0 and fs
.
returnsthe frequency response vector, h
= freqz(___,w
)h
, at the normalizedfrequencies supplied in w
.
returnsthe frequency response vector, h
= freqz(___,f
,fs
)h
, at the physicalfrequencies supplied in f
.
example
freqz(___)
withno output arguments plots the frequency response of the filter.
Note: If the input to freqz
issingle precision, the frequency response is calculated using single-precisionarithmetic. The output, h
, is single precision.
FREQZ 是计算数字滤波器的频率响应的函数
[H,W] = FREQZ(B,A,N) returns the N-point complex frequency response
vector H and the N-point frequency vector W in radians/sample of
the filter:
函数的输出:a.滤波器的频率响应H(N点) b.频率向量W(N点,且单位为弧度)
其中,滤波器形式如下:
given numerator and denominator coefficients in vectors B and A. The
frequency response is evaluated at N points equally spaced around the
upper half of the unit circle. If N isn't specified, it defaults to 512.
滤波器的系数:
分子为B,分母为A
频率向量W,是均匀分布在滤波器的上半区,即:0:pi,这些点上的频率响应都将通过此函数计算出来。
举例:
假设滤波器的系数A=1,B=【1 1/2 1/3 1/4】;通过FREQZ函数便可以得到此滤波器的频率特性
其中,需要考察的是H和W的长度,看是否符合我们设置的N。
[H,W] = FREQZ(B,A,N,'whole') uses N points around the whole unit circle.函数给出了滤波器的双边频率特性,是N点的
H = FREQZ(B,A,W) returns the frequency response at frequencies
designated in vector W, in radians/sample (normally between 0 and pi).
函数的输出依然是滤波器的频率响应H,只不过这个H是限定了范围的,不再是全频率(0:pi)上的了,这个范围由W来指定,单位是弧度。
举例:W=【0.5pi----pi】,下图中,红线部分便是此函数的输出,可见,只描述了【0.5pi----pi】之间的频率响应。
[H,F] = FREQZ(B,A,N,Fs) and [H,F] = FREQZ(B,A,N,'whole',Fs) return
frequency vector F (in Hz), where Fs is the sampling frequency (in Hz).
注意下图的横坐标与程序中fs的关系
H = FREQZ(B,A,F,Fs) returns the complex frequency response at the
frequencies designated in vector F (in Hz), where Fs is the sampling
frequency (in Hz).
FREQZ(B,A,...) with no output arguments plots the magnitude and
unwrapped phase of the filter in the current figure window.
MATLAB提供了专门用于求离散系统频响特性的函数freqz(),调用freqz()的格式有以下两种:
(1)[H,w]=freqz(B,A,N)
(2)[H,w]=freqz(B,A,N,’whole’)
(1)中B和A分别为离散系统的系统函数分子、分母多项式的系数向量,返回量H则包含了离散系统频响在0~pi范围内N个频率等分点的值(其中N为正整数),w则包含了范围内N个频率等分点。调用默认的N时,其值是512。
(2)中调用格式将计算离散系统在0~pi范内的N个频率等分店的频率响应的值。
因此,可以先调用freqz()函数计算系统的频率响应,然后利用abs()和angle()函数及plot()函数,即可绘制出系统在或 范围内的频响曲线。
绘制如下系统的频响曲线
H(z)=(z-0.5)/z
MATLAB命令如下:
B=[1-0.5];
A =[10];
[H,w]=freqz(B,A,400,'whole');
Hf=abs(H);
Hx=angle(H);
clf
figure(1)
plot(w,Hf)
title('离散系统幅频特性曲线')
figure(2)
plot(w,Hx)
title('离散系统相频特性曲线')