Int32 ChebyshevIIOrder(Double[] BEdges, Double PassRipple, Double StopRipple, TFilterType FilterType, ref Double[] CutoffFreq, Boolean Analog)
Estimate the minimum Chebyshev type II (inverse Chebyshev) filter order that meets a transition-band specification, and fill CutoffFreq with the STOPBAND-edge cutoff(s). The order formula matches Chebyshev type I, n=\lceil(cosh^(-1)sqrt((10^(R_s/10)-1)/(10^(R_p/10)-1)))/(cosh^(-1)(omega_s/omega_p))\rceil, capped at MaxIirOrder (=50). Because the natural cutoff is the stopband edge, the returned CutoffFreq may sit just outside the passband bracket; for bandpass/bandstop the estimated order can differ from scipy cheb2ord by at most one section. Domain: digital edges in (Analog=False) or analog rad/s (Analog=True); CutoffFreq length is half BEdges length and matches FilterType.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | BEdges | Double[] | |
| 2 | PassRipple | Double | scalar |
| 3 | StopRipple | Double | scalar |
| 4 | FilterType | TFilterType | |
| 5 | CutoffFreq | Double[] (ref) | |
| 6 | Analog | Boolean |
Returns: Int32
Returns the order of the Chebyshev type II filter. 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 ChebyshevIIFilter routine.
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 Wc,k;
double[] WcArray = new double[2];
int Order; //design a fifth order filter.
Order = IIRFilters.ChebyshevIIOrder(new double[4] { 1, 3, 6, 9 }, 0.2, 50, TFilterType.ftBandpass, ref WcArray, true); //design analog protype
IIRFilters.ChebyshevIIAnalog(Order, 50, z, p, out k); //design analog protype
Wc = Math.Sqrt(WcArray[0] * WcArray[1]); //modified 3dB frequency
double Bw = WcArray[1] - WcArray[0];
LinearSystems.LowpassToBandpass(z, p, ref k, Wc, Bw); //frequency transformation in s-domain
LinearSystems.ZeroPoleToTransferFun(num, den, z, p, k);
FreqFr.Length = 1000;
SignalUtils.LogRamp(FreqFr, -1, 1);
SignalUtils.FrequencyResponseS(num, den, FreqFr, Response, 0);
MtxVecTee.DrawIt(Response, "Frequency response", false);
}