function EllipticOrder(BEdges: TDoubleArray; PassRipple: Double; StopRipple: Double; FilterType: TFilterType; var CutoffFreq: TDoubleArray; Analog: Boolean): Integer;
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 (Analog=False) or analog rad/s (Analog=True); CutoffFreq length is half BEdges length and matches FilterType.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | BEdges | TDoubleArray | |
| 2 | PassRipple | Double | scalar |
| 3 | StopRipple | Double | scalar |
| 4 | FilterType | TFilterType | |
| 5 | CutoffFreq | TDoubleArray | |
| 6 | Analog | Boolean |
Returns: Int32
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.
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit, IirFilters,
LinearSystems;
procedure TForm1.Button1Click(Sender: TObject);
var z,p, num,den, FreqFr,Response: Vector;
Order: integer;
k,Bw,Wc: double;
WcArray: TDoubleArray; //modified 3dB frequency
begin
SetLength(WcArray,2);
Order := EllipticOrder([0.2,0.3,0.6,0.7],0.2,50,ftBandstop,WcArray);
EllipticAnalog(Order,0.2,50,z,p,k); //design analog protype
Bilinear(z,p,k,2); //Sampling frequency is 2
Wc := Sqrt(WcArray[0]*WcArray[1]); //modified 3dB frequency
Bw := WcArray[1] - WcArray[0];
LowpassToBandstopZ(z,p,k,Wc,Bw,BilinearUnwarp(1)); //frequency transformation in z-domain
ZeroPoleToTransferFun(num,den,z,p,k);
FrequencyResponse(num,den,Response,64);
DrawIt(Response);
end;