Engee documentation

lowpass

The signals after the low-pass filter.

Library

EngeeDSP

Syntax

Function call

  • y = lowpass(x,wpass) — filters the input signal x using a low-pass filter with a normalized bandwidth frequency wpass in units rad/countdown. Function lowpass uses a minimum order filter with bandwidth attenuation 60 dB and compensates for the delay introduced by the filter. If x — matrix, the function filters each column independently.

  • y = lowpass(x,fpass,fs) — uses the sampling rate fs in Hz of the input signal x, fpass — the frequency of the filter bandwidth in Hz.

  • y = lowpass(_, Name,Value) — sets additional options for any of the previous syntaxes with one or more arguments Name,Value.

  • y = lowpass(_; out=:plot) — Plots the input signal and overlays the filtered signal.

Arguments

Input arguments

# x — input signal

+ vector | the matrix

Details

An input signal specified as a vector or matrix.

Типы данных

Float32, Float64

Support for complex numbers

Yes

# wpass — normalized bandwidth frequency

+ scalar

Details

The normalized bandwidth frequency, set as a scalar in the interval (0, 1).

# fpass — bandwidth frequency, Hz

+ scalar

Details

The bandwidth frequency, set as a scalar in the interval (0, fs/2) in Hz.

# fs — sampling rate
scalar

Details

The sampling frequency, set as a positive real scalar.

Input arguments "name-value"

Specify optional argument pairs in the format Name, Value, where Name — the name of the argument, and Value — the appropriate value. Name-value arguments should be placed after other arguments, but the order of the pairs does not matter.

Use commas to separate the name and value, and Name put it in quotation marks.

Example: f = lowpass(x, 200, fs, "StopbandAttenuation", 30).

# ImpulseResponse — type of impulse response

+ "auto" (by default) | "fir" | "iir"

Details

The type of pulse response of the filter, set as "fir", "iir" or "auto":

  • "fir" — the function designs a minimum-order filter, linear-phase, with a finite impulse response (FIR). To compensate for the delay, the function adds to the input signal zeros, where — filter order. The function then filters the signal and deletes the first ones. counts at the output.

    In this case, the input signal must be at least twice as long as the filter that meets the specifications.

  • "iir" — the function designs a minimum-order filter with infinite impulse response (BIH) and uses the function filtfilt to perform zero-phase filtering and filter delay compensation.

    If the signal is less than three times longer than the filter that meets the specification, the function designs a filter of a smaller order and, therefore, a lower steepness.

  • "auto" — the function designs a minimum-order FIR filter if the input signal is long enough, and a minimum-order FIR filter otherwise. Specifically, the function performs the following steps:

    • Calculates the minimum order that the FIR filter must have in order to meet the specifications. If the signal is at least twice as long as the required filter order, it designs and uses this filter.

    • If the signal is not long enough, calculate the minimum order that the FIR filter must have in order to meet the specifications. If the signal length is at least three times the required filter order, it designs and uses this filter.

    • If the signal length is insufficient, truncates the order to one-third of the signal length and designs an IIR filter of this order. The decrease in order occurs due to the steepness of the decline of the transition band.

    • Filters the signal and compensates for the delay.

# Steepness — steepness of the transition band decline

+ 0.85 (by default) | scalar

Details

The steepness of the transition band decline, defined as a scalar in the interval [0.5, 1). As the steepness increases, the impulse response of the filter approaches the ideal impulse response of the low-pass filter, but the resulting filter length also increases, as well as the computational cost of the filtering operation. For more information, see The steepness of the low-pass filter drop.

# StopbandAttenuation — attenuation in the delay band of the filter

+ 60 (by default) | positive scalar

Details

The attenuation in the filter’s delay band, set as a positive scalar in dB.

Output arguments

# y — filtered signal

+ vector | the matrix

Details

The filtered signal returned as a vector or matrix with the same dimensions as the input signal.

Examples

Low-frequency tone filtering

Details

We will generate a signal sampled with the frequency 1 kHz during 1 seconds. The signal contains two tones, one with a frequency 50 Hz, and the other with frequency 250 Hz, to which Gaussian white noise with dispersion is added 1/100. The amplitude of the high-frequency tone is twice the amplitude of the low-frequency tone.

import EngeeDSP.Functions: lowpass, randn

fs = 1e3
t = 0:1/fs:1
x = [1 2] * sin.(2π * [50; 250] .* reshape(t, 1, :)) + randn(1, length(t)) / 10

Let’s apply a low-pass filter to remove the low-frequency tone. Specify the bandwidth frequency 150 Hz. We will display the original and filtered signals, as well as their spectra.

lowpass(x,150,fs; out=:plot)

lowpass 1

The steepness of the low-pass filter drop

Details

Filter out the white noise sampled with the frequency 1 kHz, using a low-pass filter with infinite impulse response and bandwidth 200 Hz. We use different values of steepness. Let’s plot the spectra of the filtered signals.

import EngeeDSP.Functions: randn, lowpass, pspectrum

fs = 1000;
x = randn(20000,1);

y1 = lowpass(x,200,fs,"ImpulseResponse","iir","Steepness",0.5)
y2 = lowpass(x,200,fs,"ImpulseResponse","iir","Steepness",0.8)
y3 = lowpass(x,200,fs,"ImpulseResponse","iir","Steepness",0.95);

pspectrum([y1 y2 y3],fs,out=:plot)

lowpass 2

Additional Info

The steepness of the low-pass filter drop

Details

Argument Steepness controls the width of the filter transition area. The lower the slope, the wider the transition area. The higher the steepness, the narrower the transition area will be.

To interpret the steepness of the filter decline, consider the following definitions:

  • _ Nyquist Frequency_ — the highest frequency component of the signal that can be sampled at a given frequency without distortion. The Nyquist frequency is rad/countdown if the input signal does not contain time information, and Hz, if you set the sampling rate.

  • _ Frequency of the delay band_ of the filter — the frequency below which the attenuation is equal to or greater than the value set using StopbandAttenuation.

  • transfer band of the filter , where — preset bandwidth frequency fpass.

  • Most imperfect filters also attenuate the input signal in the bandwidth. The maximum value of this frequency-dependent attenuation is called the bandwidth pulsation. Each filter used in lowpass it has ripples in the bandwidth 0.1 dB.

lowpass en

When for Steepness the value is specified , lowpass calculates the width of the transition as

  • When Steepness equally 0.5, the width of the transition is 50% of .

  • As it gets closer Steepness to 1 the width of the transition gradually decreases until it reaches the minimum value in 1% of .

The default value is Steepness equally 0.85, which corresponds to the width of the transition, which is 15.7% of .