ELLIP
Elliptic filters, also known as Cauer filters, are designed to have ripple in both the passband and the stopband.
For a given order and given maximum passband ripple and minimum stopband attenuation, elliptic filters provide the steepest roll-off of all the standard filter types (Butterworth, Chebyshev Type I and II).
Excel Usage
=ELLIP(N, rp, rs, Wn, btype, filter_output_form, analog, fs)
N(int, required): The order of the filter.rp(float, required): The maximum ripple allowed below unity gain in the passband (dB).rs(float, required): The minimum attenuation required in the stop band (dB).Wn(list[list], required): Critical frequency or frequencies.btype(str, optional, default: “lowpass”): The type of filter.filter_output_form(str, optional, default: “ba”): Type of output representation.analog(bool, optional, default: false): When True, return an analog filter.fs(float, optional, default: null): The sampling frequency of the digital system.
Returns (list[list]): Filter coefficients or representation as a 2D array.
Example 1: Low-pass (b, a)
Inputs:
| N | rp | rs | Wn | btype |
|---|---|---|---|---|
| 2 | 1 | 40 | 0.1 | lowpass |
Excel formula:
=ELLIP(2, 1, 40, 0.1, "lowpass")
Expected output:
| Result | ||
|---|---|---|
| 0.0289618 | 0.024609 | 0.0289618 |
| 1 | -1.61943 | 0.712032 |
Example 2: High-pass (b, a)
Inputs:
| N | rp | rs | Wn | fs | btype |
|---|---|---|---|---|---|
| 4 | 0.5 | 60 | 100 | 1000 | highpass |
Excel formula:
=ELLIP(4, 0.5, 60, 100, 1000, "highpass")
Expected output:
| Result | ||||
|---|---|---|---|---|
| 0.39801 | -1.56852 | 2.3412 | -1.56852 | 0.39801 |
| 1 | -2.22489 | 2.18891 | -1.00736 | 0.224874 |
Python Code
Show Code
import numpy as np
from scipy.signal import ellip as scipy_ellip
def ellip(N, rp, rs, Wn, btype='lowpass', filter_output_form='ba', analog=False, fs=None):
"""
Elliptic (Cauer) digital and analog filter design.
See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.ellip.html
This example function is provided as-is without any representation of accuracy.
Args:
N (int): The order of the filter.
rp (float): The maximum ripple allowed below unity gain in the passband (dB).
rs (float): The minimum attenuation required in the stop band (dB).
Wn (list[list]): Critical frequency or frequencies.
btype (str, optional): The type of filter. Valid options: Lowpass, Highpass, Bandpass, Bandstop. Default is 'lowpass'.
filter_output_form (str, optional): Type of output representation. Valid options: Numerator/Denominator, Pole-Zero, Second-Order Sections. Default is 'ba'.
analog (bool, optional): When True, return an analog filter. Default is False.
fs (float, optional): The sampling frequency of the digital system. Default is None.
Returns:
list[list]: Filter coefficients or representation as a 2D array.
"""
try:
if isinstance(Wn, list):
wn_flat = [float(v) for row in Wn for v in row]
wn_val = wn_flat[0] if len(wn_flat) == 1 else wn_flat
else:
wn_val = float(Wn)
result = scipy_ellip(
int(N),
float(rp),
float(rs),
wn_val,
btype=btype,
analog=bool(analog),
output=filter_output_form,
fs=float(fs) if fs is not None else None
)
if filter_output_form == 'ba':
b, a = result
max_len = max(len(b), len(a))
return [b.tolist() + [""] * (max_len - len(b)), a.tolist() + [""] * (max_len - len(a))]
elif filter_output_form == 'zpk':
z, p, k = result
max_len = max(len(z), len(p), 1)
return [z.tolist() + [""] * (max_len - len(z)), p.tolist() + [""] * (max_len - len(p)), [float(k)] + [""] * (max_len - 1)]
else: # sos
return result.tolist()
except Exception as e:
return f"Error: {str(e)}"Online Calculator
The order of the filter.
The maximum ripple allowed below unity gain in the passband (dB).
The minimum attenuation required in the stop band (dB).
Critical frequency or frequencies.
The type of filter.
Type of output representation.
When True, return an analog filter.
The sampling frequency of the digital system.