Accelerating the pace of engineering and science

• Trials

# zerophase

Zero-phase response of digital filter

## Syntax

[Hr,w]=zerophase(b,a)
[Hr,w] = zerophase(sos)
[Hr,w] = zerophase(Hd)
[Hr,w]=zerophase(...,nfft)
[Hr,w] = zerophase(...,nfft,'whole')
[Hr,w]=zerophase(...,w)
[Hr,f] = zerophase(...,f,fs)
[Hr,w,phi] = zerophase(...)
zerophase(...)

## Description

[Hr,w] = zerophase(b,a) returns the zero-phase response Hr, and the frequency vector w (in radians/sample) at which Hr is computed, given a filter defined by numerator b and denominator a. For FIR filters where a=1, you can omit the value a from the command. The zero-phase response is evaluated at 512 equally spaced points on the upper half of the unit circle.

The zero-phase response, H(ω), is related to the frequency response, H(ω) by

where H(e) is the frequency response, Hr(ω) is the zero-phase response and φ(ω) is the continuous phase.

 Note   The zero-phase response is always real, but it is not the equivalent of the magnitude response. The former can be negative while the latter cannot be negative.

[Hr,w] = zerophase(sos) returns the zero-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, zerophase 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)].

[Hr,w] = zerophase(Hd) returns the zero-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 Hr is the zero-phase response of the corresponding dfilt object.

[Hr,w] = zerophase(...,nfft) returns the zero-phase response Hr and frequency vector w (radians/sample), using nfft frequency points on the upper half of the unit circle.

[Hr,w] = zerophase(...,nfft,'whole') returns the zero-phase response Hr and frequency vector w (radians/sample), using nfft frequency points around the whole unit circle.

[Hr,w] = zerophase(...,w) returns the zero-phase response Hr and frequency vector w (radians/sample) at frequencies in vector w. The vector w must have at least two elements.

[Hr,f] = zerophase(...,f,fs) returns the zero-phase response Hr and frequency vector f (Hz), using the sampling frequency fs (in Hz), to determine the frequency vector f (in Hz) at which Hr is computed. The vector f must have at least two elements.

[Hr,w,phi] = zerophase(...) returns the zero-phase response Hr, frequency vector w (rad/sample), and the continuous phase component, phi. (Note that this quantity is not equivalent to the phase response of the filter when the zero-phase response is negative.)

zerophase(...) plots the zero-phase response versus frequency. The plot is displayed in the current figure window. If the input is the numerator and denominator coefficients, a second order sections matrix, or a single dfilt object, the zero–phase response of the single filter is displayed. If the input is an array of dfilt objects, the zero–phase responses of all filters in the array are displayed.

 Note:   If the input to zerophase is single precision, the zero-phase response is calculated using single-precision arithmetic. The output, Hr, is single precision.

## Examples

### Example 1

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

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

### Example 2

Plot the zero-phase response of an elliptic filter:

```[b,a]=ellip(10,.5,20,.4);
zerophase(b,a,512,'whole');
```