function ChebyshevIOrder(BEdges: TDoubleArray; PassRipple: Double; StopRipple: Double; FilterType: TFilterType; var CutoffFreq: TDoubleArray; Analog: Boolean): Integer;
Estimate the minimum Chebyshev type I filter order that meets a transition-band specification, and fill CutoffFreq with the passband-edge cutoff(s). The order is 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), where R_p=PassRipple and R_s=StopRipple in dB. BEdges holds the band edges ascending; CutoffFreq length must be half BEdges length and match FilterType. Domain: digital edges in (sampling frequency 2, Analog=False) or analog rad/s (Analog=True). The returned cutoff is the passband edge.
| # | 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
Returns the order of the Chebyshev type I 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 ChebyshevIFilter 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: double;
WcArray: TDoubleArray; //modified 3dB frequency
begin
SetLength(WcArray,1);
Order := ChebyshevIOrder([1,4],0.1,50,ftHighpass,WcArray,True);
ChebyshevIAnalog(Order,0.1,z,p,k); //design analog protype
LowpassToHighpass(z,p,k,WcArray[0]); //frequency transformation in s-domain
ZeroPoleToTransferFun(num,den,z,p,k);
FreqFr.Length := 1000; //Define the frequency grid (logarithmic)
LogRamp(FreqFr,-1,1); //between 0.1 (=10^(-1)) and 10 (=10^1) rad/sec
FrequencyResponseS(num,den,FreqFr,Response); //Laplace
DrawIt(Response); //Y axis linear, X axis logarithmic;
end;