You are here: Symbol Reference > Dew Namespace > Dew.Signal Namespace > Dew.Signal.Units Namespace > Classes > SignalUtils Class > SignalUtils Methods > SignalUtils.KaiserImpulse Method
Dew Signal for .NET
ContentsIndexHome
PreviousUpNext
SignalUtils.KaiserImpulse Method

Design a FIR filter with a Kaiser window.

Syntax
C#
Visual Basic
public static void KaiserImpulse([In] TVec H, double[] W, double Ripple, TFilterType FilterType, double Gain, double FS, bool EnsuredOdd);

Compute a FIR impulse response filter with kaiser window applied and place the result in H. The transition regions are defined with the W array. There must be at least one (lowpass, highpass) and at most two (bandpass, bandstop) transition regions (2 or 4 elements). Filter type is defined with TFilterType

FS is the sampling frequency. The length of the filter (H.Length) is based on the narrowest transition region in combination with the passband Ripple parameter. 20*Log10(Ripple) is also the required attenuation of the stopband in decibel. Gain defines the filter gain. The resulting H vector contains FIR type impulse response, which can be passed to the FirInit routine. 

If EnsuredOdd is True, the filter length is guaranteed to have odd length. H.FloatPrecision value on input defines the precision (single or double) of the result on output.

Impulse responses of FIR filters windowed with the Kaiser window.

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, TMtxFloatPrecision.mvDouble, 0,1.0/response.Length); MtxVecTee.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); MtxVecTee.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, TMtxFloatPrecision.mvDouble,0,1.0/response.Length); MtxVecTee.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, TMtxFloatPrecision.mvDouble,0,1.0/response.Length); MtxVecTee.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, TMtxFloatPrecision.mvDouble,0,1.0/response.Length); MtxVecTee.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, TMtxFloatPrecision.mvDouble,0,1.0/response.Length); MtxVecTee.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, TMtxFloatPrecision.mvDouble,0,1.0/response.Length); MtxVecTee.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, TMtxFloatPrecision.mvDouble,0,1.0/response.Length); MtxVecTee.DrawIt(x, response,"Differentiator IV with transitions between 0.0-0.1 Hz",false); }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!