Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# phasez

Phase response of digital filter

## Syntax

[phi,w] = phasez(b,a,n)
[phi,w] = phasez(sos,n)
[phi,w]=phasez(Hd,n)
[phi,w] = phasez(...,n,'whole')
phi = phasez(...,w)
[phi,f] = phasez(...,n,fs)
phi = phasez(...f,fs)
[phi,w,s] = phasez(...)
phasez(...)

## Description

[phi,w] = phasez(b,a,n) returns the n-point unwrapped phase response vector, phi, in radians and frequency vector, w, in radians/sample for the filter coefficients specified in b and a. The values of the frequency vector, w, range from 0 to pi. If n is omitted, the length of the phase response vector defaults to 512.

[phi,w] = phasez(sos,n) returns the unwrapped phase response for the second order sections matrix, sos. sos is a K-by-6 matrix, where the number of sections, K, must be greater than or equal to 2. If the number of sections is less than 2, phasez considers the input to be the numerator vector, b. Each row of sos corresponds to the coefficients of a second order (biquad) filter. The i-th row of the sos matrix corresponds to [bi(1) bi(2) bi(3) ai(1) ai(2) ai(3)].

[phi,w]=phasez(Hd,n) returns the unwrapped phase response for the dfilt filter object, Hd, or the array of dfilt filter objects. If Hd is an array of dfilt objects, each column of phi is the group delay of the corresponding dfilt object. If n is unspecified for discrete-time filter objects, the length of the phase response vector defaults to 8192.

[phi,w] = phasez(...,n,'whole') returns frequency and unwrapped phase response vectors evaluated at n equally-spaced points around the unit circle from 0 to 2*pi radians/sample.

phi = phasez(...,w) returns the unwrapped phase response in radians at frequencies specified in w (radians/sample). The frequencies are normally between 0 and pi.The vector w must have at least two elements.

[phi,f] = phasez(...,n,fs) return the unwrapped phase vector phi in radians and the frequency vector in Hz. The frequency vector ranges from 0 to the Nyquist frequency, fs/2. If the 'whole' option is used, the frequency vector ranges from 0 to the sampling frequency.

phi = phasez(...f,fs) return the phase response in radians at the frequencies specified in the vector f (in Hz) using the sampling frequency fs (in Hz). The vector f must have at least two elements.

[phi,w,s] = phasez(...) return plotting information, where s is a structure array with fields you can change to display different frequency response plots.

phasez(...) with no output arguments plots the phase response of the filter. If you input the filter coefficients or second order sections matrix, the current figure window is used. If you input a discrete-time filter object or array of filter objects, fvtool is used to plot the phase response.

 Note:   If the input to phasez is single precision, the phase response is calculated using single-precision arithmetic. The output, phi, is single precision.

## Examples

### Example 1

Plot the phase response of a constrained least squares FIR filter:

```b=fircls1(54,.3,.02,.008);
phasez(b)
```

### Example 2

In the next example, we design an equiripple lowpass default filter object and display the result:

```d=fdesign.lowpass;
Hd=design(d,'equiripple');
phasez(Hd)```

### Example 3

Plot the phase response of an elliptic filter:

```d=fdesign.lowpass('Fp,Fst,Ap,Ast',0.4,0.5,1,60);
Hd=design(d,'ellip');
phasez(Hd)```