Engee documentation

impz

The pulse response of the digital filter.

Library

EngeeDSP

Syntax

Function call

  • h,t = impz(b,a) — returns the pulse response of the specified digital filter. Specify a digital filter with numerator coefficients b and the coefficients of the denominator a. The function selects time samples and returns the coefficients of the characteristic in the output argument. h and the sampling periods in the output argument t.

  • h,t = impz(B,A,"ctf") — returns the pulse response of the digital filter, represented as Cascaded Transfer Functions (CTF) with numerator coefficients B and the coefficients of the denominator A.

  • h,t = impz((B,A,g),"ctf") — returns the pulse response of a digital filter in CTF format. Specify a filter with numerator coefficients B, the coefficients of the denominator A and scale values g by filter sections.

  • h,t = impz(sos) — returns the impulse response of a filter specified by a matrix of second-order sections sos.

  • h,t = impz(___,n) — sets the number of pulse response samples to be calculated. You can specify a filter using any of the previous syntaxes.

  • h,t = impz(___,n,fs) — returns a vector t with consecutive counts located at a distance 1/fs units apart.

  • impz(___,out=:plot) — plots the pulse response of the filter.

Arguments

Input arguments

# b,a are the coefficients of the transfer function

+ vectors

Details

The coefficients of the transfer function, set as vectors. The transfer function is expressed in terms of b and a as follows:

Типы данных

Float64, Float32

Support for complex numbers

Yes

# B,A are the coefficients of the cascade transfer function

+ scalars | vectors | matrices

Details

The coefficients of the cascade transfer function, specified as scalars, vectors, or matrices. In matrices B and A The coefficients of the numerator and denominator of the cascade transfer function are listed, respectively.

The matrix B must have a size of on , and the matrix A on , where

  • — number of filter sections;

  • — the order of the numerators of the filter;

  • — the order of the denominators of the filter.

For more information about the cascade transfer function format and coefficient matrices, see Setting digital filters in CTF format.

If any element of the matrix A[:,1] not equal to 1, then the function impz normalizes the filter coefficients by A[:,1]. In this case A[:,1] must be non-zero.
Типы данных

Float64, Float32

Support for complex numbers

Yes

# g — scale values

+ scalar | vector

Details

Scale values specified as a real scalar or vector with real values containing the element where — the number of sections of the cascade transfer function. The scale values represent the distribution of the filter gain across the sections of the cascade filter representation.

Function impz applies the gain to the filter sections using the function scaleFilterSections depending on the way the argument is set g:

  • scalar — the function evenly distributes the gain across all sections of the filter;

  • vector — the function applies the first applies the gain values to the corresponding filter sections and distributes the last gain value evenly across all filter sections.

Типы данных

Float64, Float32

# sos — coefficients of the sections of the second order

+ the matrix

Details

Coefficients of the second-order sections, specified as a matrix. Argument sos — this is a matrix of size on , where is the number of sections must be greater than or equal to 2. If the number of sections is less 2, the function processes the input data as a vector of numerators. Each line sos corresponds to the coefficients of the second-order filter (biquadrate filter); - I’m a string sos respond [bi[1] bi[2] bi[3] ai[1] ai[2] ai[3]].

Типы данных

Float64, Float32

Support for complex numbers

Yes

# n is the number of points by which the characteristic is evaluated

+ a positive integer | a vector of non-negative integers | []

Details

The number of points used to evaluate a characteristic, given as a positive integer, a vector of non-negative integers, or an empty vector.

  • If the argument is n — positive integer, function impz calculates the first ones n counts the pulse response and returns t how [0:n−1]'.

  • If n — vector of non-negative integers, function impz calculates the impulse response at the points indicated in the vector.

  • If n — empty vector, function impz calculates the number of samples automatically. See Algorithms for more information.

# fs — sampling rate
scalar

Details

The sampling rate, set as a positive scalar. If the unit of time is seconds, then fs expressed in Hz.

Типы данных

Float64

Name-value input arguments

Specify optional argument pairs as Name=Value, where Name — the name of the argument, and Value — the appropriate value.

# out — type of output data

+ :data (by default) | :plot

Details

Type of output data:

  • :data — the function returns data;

  • :plot — the function returns a graph.

Output arguments

# h — pulse response coefficients

+ vector

Details

The coefficients of the impulse response returned as a column vector.

# t — sampling periods

+ vector

Details

Sampling periods returned as a column vector.

Examples

Pulse response of an elliptical low-pass filter

Details

Let’s design a fourth-order elliptical low-pass filter with a normalized bandwidth frequency 0.4 rad/countdown. Setting the ripple in the bandwidth 0.5 dB and attenuation in the suppression band 20 dB. Let’s build a graph of the first 50 pulse response counts.

import EngeeDSP.Functions: ellip, impz

b, a = ellip(4, 0.5, 20, 0.4)
impz(b, a, 50, out = :plot)

impz 1

Pulse response of a high-pass FIR filter

Details

Let’s design a high-pass FIR filter 18-th order, using the Kaiser window with . Setting the sampling frequency 100 Hz and cutoff frequency 30 Hz. Display the pulse response of the filter.

import EngeeDSP.Functions: fir1, kaiser, impz

b = fir1(18, 30/(100/2), kaiser(19, 4), "high")
impz(b, 1, [], 100, out = :plot)

impz 2

Calculation of the impulse response for cascade transfer functions

Details

Let’s design a Chebyshev type II digital low-pass filter 40-th order with a boundary frequency in the barrier band 0.4 and attenuation in the barrier strip 50 dB. Let’s build a graph of the first 64 samples of the pulse response of the filter using the filter coefficients in CTF format.

import EngeeDSP.Functions: impz, cheby2

B, A = cheby2(40, 50, 0.4)

impz(B, A, 64, out = :plot)

impz 3

Additional Info

Cascading transfer functions

Details

Splitting a digital IIR filter into cascaded sections increases its numerical stability and reduces its susceptibility to coefficient quantization errors. Cascade form of the transfer function expressed in terms of transfer functions , has the form

butter en

Setting digital filters in CTF format

Details

Digital filters can be designed in CTF format to analyze, visualize, and filter signals. The filter is set by enumerating its coefficients B and A. You can also specify the scaling factor of the filter by sections by setting a scalar or vector value. g.

coeffects of the filter

When setting coefficients in the form -lowercase matrices

it is assumed that the filter is set as a sequence of cascade transfer functions, so that the complete transfer function of the filter has the form

where — the order of the filter numerator, and — the order of the denominator.

  • If and defined as vectors, it is assumed that the basic system is a single-section IIR filter ( ), where represents the numerator of the transfer function, and — its denominator.

  • If — scalar, it is assumed that the filter is a cascade of IIR filters with poles, and the total gain of the system of each cascade is equal to .

  • If — scalar, it is assumed that the filter is a cascade of FIR filters, and the total gain of the system of each cascade is equal to .

  • To convert second-order section matrices into cascade transfer functions, use the function sos2ctf.

  • To convert the filter representation with zeros, poles, and gain into cascaded transfer functions, use the function zp2ctf.

coeffects and amplification

If there is a common scale gain or several scale gain factors that are outside the values of the filter coefficients, you can specify the coefficients and gain as a tuple. (B, A, g). Scaling the filter sections is especially important when working with fixed-point arithmetic to ensure that the output signals of each filter section have similar amplitude levels, which helps to avoid inaccuracies in the frequency response of the filter due to limited computational accuracy.

The gain can be a scalar total gain or a vector of section gain coefficients.

  • If the gain is scalar, its value is applied uniformly to all sections of the cascade filter.

  • If the gain is a vector, it must contain one element more than the number of filter sections. in the cascade. Each of the first The scale value is applied to the corresponding filter section, and the last value is applied evenly to all sections of the cascade filter.

If you specify the filter coefficient matrices and the gain coefficient vector as

it is assumed that the transfer function of the filter system has the form

Algorithms

Function impz filters a sequence of pulses of length n with the help

filter(b, a, [1 zeros(n-1)])

and plots the result using stem.

If the input data for the function is impz they have single precision, the function calculates the impulse response using single precision arithmetic, and returns the result in single precision format.

When the function impz calculates n automatically, the algorithm depends on the filter properties:

  • FIR filters — n is the length of the vector b.

  • BIH filters are a function impz first, it finds the poles of the transfer function using the function roots.

    • If the filter is unstable, n it is chosen as the point at which the term determined by the largest pole reaches -a multiple increase in its initial value.

    • If the filter is stable, n it is chosen as the point at which the term, due to the pole with the largest amplitude, in It exceeds its initial amplitude by several times.

    • If the filter is oscillating and has poles only on the unit circle, the function impz calculates the five periods of the slowest fluctuations.

    • If the filter has both oscillating and decaying terms, n — this is the largest of the five periods of the slowest oscillations, or the point at which the term due to the largest pole is in It exceeds its initial amplitude by several times.

Function impz It also allows for delays in the numerator polynomial. The number of delays is taken into account when calculating the number of counts.

Literature

  1. Lyons, Richard G. Understanding Digital Signal Processing. Upper Saddle River, NJ: Prentice Hall, 2004.