Design a digital bandstop filter with transition band between 0.2..0.3 and 0.6..0.7 Hz and with at least 50dB attenuation in the stopband and. The passband should not have more then 0.2dB ripple. The sampling frequency is 2Hz.
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 z = new Vector(0); Vector p = new Vector(0); Vector num = new Vector(0); Vector den = new Vector(0); Vector Response = new Vector(0); Vector FreqFr = new Vector(0); double k,Wc; double[] WcArray = new double[2]; int Order; //design a fifth order filter. double FS = 2; Order = IIRFilters.EllipticOrder(new double[4] { 0.2, 0.3, 0.6, 0.7 }, 0.2, 50, TFilterType.ftBandStop, ref WcArray, true); //design analog protype IIRFilters.EllipticAnalog(Order, 0.2, 50, z, p, out k); //design analog protype LinearSystems.Bilinear(z, p, ref k, FS, true); Wc = Math.Sqrt(WcArray[0] * WcArray[1]); //modified 3dB frequency double Bw = WcArray[1] - WcArray[0]; LinearSystems.LowpassToBandStopZ(z, p, ref k, Wc, Bw, LinearSystems.BilinearUnwarp(1,FS)); LinearSystems.ZeroPoleToTransferFun(num, den, z, p, k); SignalUtils.FrequencyResponse(num, den, Response, 32, false, TSignalWindowType.wtRectangular, 0); TeeChart.DrawIt(Response, "Frequency response", false); }
|
Copyright (c) 1999-2010 by Dew Research. All rights reserved.
|