Unit
SignalUtils
If EnsuredOdd is True, the filter length is guaranteed to have odd length.
| See Also |
|---|
| FirFilter |
| KaiserFirLength |
| RemezFirLength |
| RemezImpulse |
| Kaiser |
| FirImpulse |
| FractionalKaiserImpulse |
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit; procedure TForm1.Button1Click(Sender: TObject); var FS, Ripple: TSample; H,Response, X: Vector; begin FS := 2; //sampling frequency Ripple := 0.001; // 60 dB stopband and 0.001 ripple in the passband // Lowpass design with transition band between 0.3 and 0.5 Hz. KaiserImpulse(H, [0.3,0.5], ripple, ftlowpass,1,FS); FrequencyResponse(H,nil,Response,8); X := Ramp(Response.Length,0,1.0/Response.Length); DrawIt(X,Response,'Lowpass design with transition band between 0.3 and 0.5 Hz',false); // Highpass design with transition band between 0.3 and 0.5 Hz. KaiserImpulse(H, [0.3,0.5], Ripple,ftHighpass,1,FS); FrequencyResponse(H,nil,Response,8); DrawIt(X,Response,'Highpass design with transition band between 0.3 and 0.5 Hz',false); // Bandpass design with transition bands between 0.3..0.4 Hz and between 0.5...06 Hz. KaiserImpulse(H, [0.3,0.4,0.5,0.6], Ripple,ftBandpass,1,FS); FrequencyResponse(H,nil,Response,8); X := Ramp(Response.Length,0,1.0/Response.Length); DrawIt(X,Response,'Bandpass with transition bands 0.3-0.4 Hz and 0.5-0.6 Hz.',false); // Bandstop design with transition bands between 0.3..0.4 Hz and between 0.5...06 Hz. KaiserImpulse(H, [0.3,0.4,0.5,0.6], Ripple,ftBandstop,1,FS); FrequencyResponse(H,nil,Response,8); X := Ramp(Response.Length,0,1.0/Response.Length); DrawIt(X,Response,'Bandstop with transition bands 0.3-0.4 Hz and 0.5-0.6 Hz.',false); //Hilbert III with transition bands between 0.0-0.1 Hz and 0.9-1.0 Hz. KaiserImpulse(H, [0.9,1], Ripple,ftHilbertIII,1,FS); FrequencyResponse(H,nil,Response,8); X := Ramp(Response.Length,0,1.0/Response.Length); DrawIt(X,Response,'Hilbert III with transition bands between 0.0-0.1 Hz and 0.9-1.0 Hz.',false); //Hilbert IV with transition band between 0.0-0.1 Hz. KaiserImpulse(H, [0.9,1], Ripple,ftHilbertIV,1,FS); FrequencyResponse(H,nil,Response,8); X := Ramp(Response.Length,0,1.0/Response.Length); DrawIt(X,Response,'Hilbert IV with transition band between 0.0-0.1 Hz',false); //Differentiator III with transition band between 0.0-0.1 and 0.9-1.0 Hz. KaiserImpulse(H, [0.9,1], Ripple,ftDifferentiatorIII,1,FS); FrequencyResponse(H,nil,Response,8); X := Ramp(Response.Length,0,1.0/Response.Length); DrawIt(X,Response,'Differentiator III with transitions between 0.0-0.1 and 0.9-1.0 Hz',false); //Differentiator IV with transition band between 0.0 and 0.1 Hz. KaiserImpulse(H, [0.9,1], Ripple,ftDifferentiatorIV,1,FS); FrequencyResponse(H,nil,Response,8); X := Ramp(Response.Length,0,1.0/Response.Length); DrawIt(X,Response,'Differentiator IV with transitions between 0.0-0.1 Hz',false); end;
#include "MtxVecCPP.h" //MtxVecCPP.cpp must be included in the project #include "MtxVecEdit.hpp" #include "MtxVecTee.hpp" #include "SignalUtils.hpp" void __fastcall TForm41::BitBtn1Click(TObject *Sender) { Vector H,Response, X; double FS = 2; //sampling frequency double Ripple = 0.001; // 60 dB stopband and 0.001 ripple in the passband // Lowpass design with transition band between 0.3 and 0.5 Hz. KaiserImpulse(H, OPENARRAY(double,(0.3,0.5)), Ripple, ftLowPass,1,FS); FrequencyResponse(H,NULL,Response,8); X = Ramp(Response->Length,0,1.0/Response->Length); DrawIt(X,Response,"Lowpass design with transition band between 0.3 and 0.5 Hz",false); // Highpass design with transition band between 0.3 and 0.5 Hz. KaiserImpulse(H, OPENARRAY(double,(0.3,0.5)), Ripple,ftHighPass,1,FS); FrequencyResponse(H,NULL,Response,8); DrawIt(X,Response,"Highpass design with transition band between 0.3 and 0.5 Hz",false); // Bandpass design with transition bands between 0.3..0.4 Hz and between 0.5...06 Hz. KaiserImpulse(H, OPENARRAY(double,(0.3,0.4,0.5,0.6)), Ripple,ftBandPass,1,FS); FrequencyResponse(H,NULL,Response,8); X = Ramp(Response->Length,0,1.0/Response->Length); DrawIt(X,Response,"Bandpass with transition bands 0.3-0.4 Hz and 0.5-0.6 Hz.",false); // Bandstop design with transition bands between 0.3..0.4 Hz and between 0.5...06 Hz. KaiserImpulse(H, OPENARRAY(double,(0.3,0.4,0.5,0.6)), Ripple,ftBandStop,1,FS); FrequencyResponse(H,NULL,Response,8); X = Ramp(Response->Length,0,1.0/Response->Length); DrawIt(X,Response,"Bandstop with transition bands 0.3-0.4 Hz and 0.5-0.6 Hz.",false); //Hilbert III with transition bands between 0.0-0.1 Hz and 0.9-1.0 Hz. KaiserImpulse(H, OPENARRAY(double,(0.9,1)), Ripple,ftHilbertIII,1,FS); FrequencyResponse(H,NULL,Response,8); X = Ramp(Response->Length,0,1.0/Response->Length); DrawIt(X,Response,"Hilbert III with transition bands between 0.0-0.1 Hz and 0.9-1.0 Hz.",false); //Hilbert IV with transition band between 0.0-0.1 Hz. KaiserImpulse(H, OPENARRAY(double,(0.9,1)), Ripple,ftHilbertIV,1,FS); FrequencyResponse(H,NULL,Response,8); X = Ramp(Response->Length,0,1.0/Response->Length); DrawIt(X,Response,"Hilbert IV with transition band between 0.0-0.1 Hz",false); //Differentiator III with transition band between 0.0-0.1 and 0.9-1.0 Hz. KaiserImpulse(H, OPENARRAY(double,(0.9,1)), Ripple,ftDifferentiatorIII,1,FS); FrequencyResponse(H,NULL,Response,8); X = Ramp(Response->Length,0,1.0/Response->Length); DrawIt(X,Response,"Differentiator III with transitions between 0.0-0.1 and 0.9-1.0 Hz",false); //Differentiator IV with transition band between 0.0 and 0.1 Hz. KaiserImpulse(H, OPENARRAY(double,(0.9,1)), Ripple,ftDifferentiatorIV,1,FS); FrequencyResponse(H,NULL,Response,8); X = Ramp(Response->Length,0,1.0/Response->Length); DrawIt(X,Response,"Differentiator IV with transitions between 0.0-0.1 Hz",false); }
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 h = new Vector(0); Vector response = new Vector(0); Vector x; double FS = 2; //sampling frequency double Ripple = 0.001; // 60 dB stopband and 0.001 ripple in the passband // Lowpass design with transition band between 0.3 and 0.5 Hz. SignalUtils.KaiserImpulse(h, new double[2] {0.3,0.5} , Ripple, TFilterType.ftLowPass,1,FS,true); SignalUtils.FrequencyResponse(h, null, response,8,false, TSignalWindowType.wtRectangular,0); x = MtxExpr.Ramp(response.Length,0,1.0/response.Length); TeeChart.DrawIt(x, response,"Lowpass design with transition band between 0.3 and 0.5 Hz",false); // Highpass design with transition band between 0.3 and 0.5 Hz. SignalUtils.KaiserImpulse(h, new double[2] {0.3,0.5} , Ripple,TFilterType.ftHighPass,1,FS,true); SignalUtils.FrequencyResponse(h, null, response,8,false, TSignalWindowType.wtRectangular,0); TeeChart.DrawIt(x, response,"Highpass design with transition band between 0.3 and 0.5 Hz",false); // Bandpass design with transition bands between 0.3..0.4 Hz and between 0.5...06 Hz. SignalUtils.KaiserImpulse(h, new double[4] {0.3,0.4,0.5,0.6} , Ripple,TFilterType.ftBandPass,1,FS,true); SignalUtils.FrequencyResponse(h, null, response,8, false,TSignalWindowType.wtRectangular,0); x = MtxExpr.Ramp(response.Length,0,1.0/response.Length); TeeChart.DrawIt(x, response,"Bandpass with transition bands 0.3-0.4 Hz and 0.5-0.6 Hz.",false); // Bandstop design with transition bands between 0.3..0.4 Hz and between 0.5...06 Hz. SignalUtils.KaiserImpulse(h, new double[4] {0.3,0.4,0.5,0.6} , Ripple,TFilterType.ftBandStop,1,FS,false); SignalUtils.FrequencyResponse(h, null, response,8, false, TSignalWindowType.wtRectangular,0); x = MtxExpr.Ramp(response.Length,0,1.0/response.Length); TeeChart.DrawIt(x, response,"Bandstop with transition bands 0.3-0.4 Hz and 0.5-0.6 Hz.",false); //Hilbert III with transition bands between 0.0-0.1 Hz and 0.9-1.0 Hz. SignalUtils.KaiserImpulse(h, new double[2] {0.9,1} , Ripple,TFilterType.ftHilbertIII,1,FS,false); SignalUtils.FrequencyResponse(h, null, response,8, false, TSignalWindowType.wtRectangular,0); x = MtxExpr.Ramp(response.Length,0,1.0/response.Length); TeeChart.DrawIt(x, response,"Hilbert III with transition bands between 0.0-0.1 Hz and 0.9-1.0 Hz.",false); //Hilbert IV with transition band between 0.0-0.1 Hz. SignalUtils.KaiserImpulse(h, new double[2] {0.9,1} , Ripple,TFilterType.ftHilbertIV,1,FS,false); SignalUtils.FrequencyResponse(h, null, response,8, false, TSignalWindowType.wtRectangular,0); x = MtxExpr.Ramp(response.Length,0,1.0/response.Length); TeeChart.DrawIt(x, response,"Hilbert IV with transition band between 0.0-0.1 Hz",false); //Differentiator III with transition band between 0.0-0.1 and 0.9-1.0 Hz. SignalUtils.KaiserImpulse(h, new double[2] {0.9,1} , Ripple,TFilterType.ftDifferentiatorIII,1,FS,false); SignalUtils.FrequencyResponse(h, null, response,8, false, TSignalWindowType.wtRectangular,0); x = MtxExpr.Ramp(response.Length,0,1.0/response.Length); TeeChart.DrawIt(x, response,"Differentiator III with transitions between 0.0-0.1 and 0.9-1.0 Hz",false); //Differentiator IV with transition band between 0.0 and 0.1 Hz. SignalUtils.KaiserImpulse(h, new double[2] {0.9,1} , Ripple,TFilterType.ftDifferentiatorIV,1,FS,false); SignalUtils.FrequencyResponse(h, null, response,8, false, TSignalWindowType.wtRectangular,0); x = MtxExpr.Ramp(response.Length,0,1.0/response.Length); TeeChart.DrawIt(x, response,"Differentiator IV with transitions between 0.0-0.1 Hz",false); }
| Copyright 2008 Dew Research |