<< fractdiff | FOSSEE_Signal_Processing_Toolbox | fwhm >>

FOSSEE_Signal_Processing_Toolbox >> FOSSEE_Signal_Processing_Toolbox > freqz

# freqz

Compute the frequency response of a digital filter.

### Syntax

    [h, w] = freqz(b, a)
    [h, w] = freqz(b, a, n)
    [h, w] = freqz(b, a, n, "whole")
    [h, w] = freqz(b, a, w)
    [h, f] = freqz(b, a, n, Fs)
    freqz(b, a, n)
    freqz(b, a)

### Parameters

b:

  Vector. The numerator coefficients of the filter's transfer function.

a:

  Vector. The denominator coefficients of the filter's transfer function. If omitted, it is assumed to be 1 (FIR filter).

n:

  Integer (optional). The number of frequency points. Default is 512.

w:

  Vector (optional). Specific frequencies (in radians) at which to evaluate the response.

Fs:

  Positive scalar (optional). Sampling frequency in Hz. If provided, frequencies are returned in Hz instead of radians.

h:

  Vector. The complex frequency response of the filter.

w:

  Vector. The frequencies (in radians) at which the response is evaluated.

f:

  Vector. The frequencies (in Hz) at which the response is evaluated.

### Description

This function computes the frequency response of a digital filter defined by its numerator (`b`) and denominator (`a`) coefficients. The response can be evaluated at a specified number of points (`n`) or at specific frequencies (`w`). If the sampling frequency (`Fs`) is provided, the frequencies are returned in Hz.

- If `a` is omitted, the filter is assumed to be an FIR filter. - If `n` is omitted, a default value of 512 is used. - If the "whole" option is specified, the response is evaluated over the entire Nyquist range (0 to 2π). Otherwise, it is evaluated over half the Nyquist range (0 to π). - If no output arguments are provided, the function plots the magnitude and phase response.

### Examples

    //Compute the frequency response of a Butterworth low-pass filter
    //Design a 4th-order Butterworth low-pass filter with cutoff frequency 0.3π
    //(normalized frequency range: 0 to 1 corresponds to 0 to π radians)
    order = 4
    fc = 0.3  // Normalized cutoff frequency (0 < fc < 1)

    [b, a] = butter(order, fc)
    freqz(b, a);

### See also

- fft1 — Calculates the discrete Fourier transform of a matrix using Fast Fourier Transform algorithm.
- unwrap2 — Unwrap radian phases in an input array.
- postpad — Append or truncate a vector or matrix to a specified length.

Report an issue
<< fractdiff | FOSSEE_Signal_Processing_Toolbox | fwhm >>