IIRFilters.EllipticOrder Method

Int32 EllipticOrder(Double[] BEdges, Double PassRipple, Double StopRipple, TFilterType FilterType, ref Double[] CutoffFreq, Boolean Analog)

Estimate the minimum elliptic (Cauer) filter order that meets a transition-band specification, and fill CutoffFreq with the passband-edge cutoff(s). Using the complete elliptic integral K( * ) and the selectivity k=omega_p/omega_s, discrimination k_1=sqrt((10^(R_p/10)-1)/(10^(R_s/10)-1)), the order is n=\lceil(K(k) K(sqrt(1-k_1^2)))/(K(sqrt(1-k^2)) K(k_1))\rceil, capped at MaxIirOrder (=50). For a given spec the elliptic order is the smallest of the five families. Domain: digital edges in (0,1)(0,1) (Analog=False) or analog rad/s (Analog=True); CutoffFreq length is half BEdges length and matches FilterType.

#NameTypeDescription
1BEdgesDouble[]
2PassRippleDoublescalar
3StopRippleDoublescalar
4FilterTypeTFilterType
5CutoffFreqDouble[] (ref)
6AnalogBoolean

Returns: Int32

Remarks:

Bedg array must contain the band edges of the transition region(s) sorted in ascending order. PassRipple defines the ripple of the passband and StopRipple defines the ripple of the stopband. The length of the CutoffFreq array must be equal to one half of the length of the BEdg array and must match the specified FilterType. The routine returns the estimated order as a result and fill's the CutoffFreq array. This array can then be passed to the EllipticFilter routine.

Examples
using Dew.Math;
using Dew.Math.Editors;
using Dew.Math.Units;
using Dew.Signal;
using Dew.Signal.Units;
using Dew.Math.Tee;
using Dew.Signal.Tee;

private void button1_Click(object sender, EventArgs e)
{
    Vector z = new Vector(0);
    Vector p = new Vector(0);
    Vector num = new Vector(0);
    Vector den = new Vector(0);
    Vector Response = new Vector(0);
    Vector FreqFr = new Vector(0);
    double k,Wc;
    double[] WcArray = new double[2];
    int Order; //design a fifth order filter.
    double FS = 2;

    Order = IIRFilters.EllipticOrder(new double[4] { 0.2, 0.3, 0.6, 0.7 }, 0.2, 50, TFilterType.ftBandstop, ref WcArray, true);  //design analog protype
    IIRFilters.EllipticAnalog(Order, 0.2, 50, z, p, out k);  //design analog protype
    LinearSystems.Bilinear(z, p, ref k, FS, true);
    Wc = Math.Sqrt(WcArray[0] * WcArray[1]); //modified 3dB frequency
    double Bw = WcArray[1] - WcArray[0];
    LinearSystems.LowpassToBandStopZ(z, p, ref k, Wc, Bw, LinearSystems.BilinearUnwarp(1,FS));
    LinearSystems.ZeroPoleToTransferFun(num, den, z, p, k);
    SignalUtils.FrequencyResponse(num, den, Response, 32, false, TSignalWindowType.wtRectangular, 0);
    MtxVecTee.DrawIt(Response, "Frequency response", false);
}
See Also: IIRFilters.EllipticFilter