|
DSP Master VCL
|
The resulting transfer function is returned in the state-space form with A,B,C,D variables.
function ChebyshevIFilter(Order: integer; PassRipple: double; const CutoffFreq: array of double; FilterType: TFilterType; Analog: boolean; const A: TMtx; const B: TVec; const C: TVec; out d: double): double; overload;
Design an analog bandpass filter with transition band between 1..2 and 5..7 rad/sec and with at least 50dB attenuation in the stopband and. The passband should not have more then 0.2dB ripple.
Note:
This example does not actually filter data. It only designs the filter. To see how to actually apply the filter check the SignalUtils.IirInit and SignalUtils.IirInitBQ routines.
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit, IirFilters, LinearSystems; {$R *.dfm} procedure TForm42.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 := ChebyshevIIOrder([1,2,5,7],0.2,50,ftBandpass,WcArray,True); ChebyshevIFilter(Order,0.2,WcArray,ftBandpass,true,num,den); 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; // Alternative: Design a digital filter with the passband between 0.2 and 0.5 Hz (FS =2) // SetLength(WcArray,2); // Order := ChebyshevIOrder([0.1,0.2,0.5,0.6],0.2,50,ftBandpass,WcArray,false); // ChebyshevIFilter(Order,0.2,WcArray,ftBandpass,false,num,den); // FrequencyResponse(num,den,Response,64); // FreqFr.Size(Response.Length); // FreqFr.Ramp(0,1/FreqFr.Length); // DrawIt(FreqFr,Response); end;
#include "MtxExpr.hpp" #include "MtxVecEdit.hpp" #include "MtxVecTee.hpp" #include "SignalUtils.hpp" #include "IirFilters.hpp" #include "LinearSystems.hpp" void __fastcall TForm1::BitBtn1Click(TObject *Sender) { sVector z,p, num, den, FreqFr, Response, WcArray; int Order; double k,Wc,Bw; WcArray.Size(2); Order = ChebyshevIIOrder(OPENARRAY(double,(1,2,5,7)),0.2,50,ftBandpass,WcArray.PValues1D(0),WcArray.Length-1,true); ChebyshevIFilter(Order,0.2,WcArray.PValues1D(0),WcArray.Length-1,ftBandpass,true,num,den); 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; //Alternative: Design a digital filter with the passband between 0.2 and 0.5 Hz (FS =2) // WcArray.Size(2); // Order = ChebyshevIOrder(OPENARRAY(double,(0.1,0.2,0.5,0.6)),0.2,50,ftBandpass,WcArray.PValues1D(0),WcArray.Length-1,false); // ChebyshevIFilter(Order,0.2,WcArray.PValues1D(0),WcArray.Length-1,ftBandpass,false,num,den); // FrequencyResponse(num,den,Response,64); // FreqFr = Ramp(Response.Length,mvDouble,0,1.0/Response.Length); // DrawIt(FreqFr,Response,"Frequency response",false); }
|
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
|
|
What do you think about this topic? Send feedback!
|