|
DSP Master VCL
|
The resulting transfer function is returned in the state-space form with A,B,C,D variables.
function BesselFilter(Order: integer; const CutoffFreq: array of double; FilterType: TFilterType; Analog: boolean; const A: TMtx; const B: TVec; const C: TVec; out d: double): double; overload;
Design a fifth order analog lowpass filter with the cutoff frequency at 3 rad/sec.
Note: This example does not actually filter data. It only designs the filter. To see how to actually apply the filter check the IirInit and IirInitBQ routines.
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 BesselFilter(5,[3],ftLowpass,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(FreqFr,20*Log10(Abs(Response))); //logarithmic frequency and amplitude 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 num, den, FreqFr, Response; BesselFilter(5,OPENARRAY(double,(3)),ftLowpass,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(FreqFr,20*Log10(Abs(Response)),"Frequency response",false); //logarithmic frequency and amplitude }
|
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
|
|
What do you think about this topic? Send feedback!
|