Frequency transformation from a lowpass to a bandstop filter in s-domain.
Example 1
Design an analog bandstop filter, where the stopband is defined with Wl = 0.2 rad/sec, Wu = 0.6 rad/sec
uses MtxExpr, Math387, MtxVec, MtxVecTee, MtxVecEdit,
LinearSystems, IirFilters, SignalUtils;
procedure TForm1.Button1Click(Sender: TObject);
var z,p, num,den, FreqFr,Response: Vector;
Order: integer;
k,Wc,BW: TSample;
begin
Order := 5; //design a fifth order filter.
EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype
Wc := Sqrt(0.2*0.6);
BW := 0.6-0.2;
LowpassToBandstop(z,p,k,WC,BW); //frequency transformation in s-domain
ZeroPoleToTransferFun(num,den,z,p,k);
//Define the frequency grid (logarithmic)
FreqFr.Length := 1000;
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
end;
#include "MtxVecCPP.h" //MtxVecCPP.cpp must be included in the project
#include "MtxVecEdit.hpp"
#include "MtxVecTee.hpp"
#include "SignalUtils.hpp"
#include "IirFilters.hpp"
#include "LinearSystems.hpp"
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
Vector z,p, num,den, FreqFr,Response;
int Order;
double k,Wc,BW;
Order = 5; //design a fifth order filter.
EllipticAnalog(Order,0.2,40,z,p,k); //design analog protype
Wc = Sqrt(0.2*0.6);
BW = 0.6-0.2;
LowpassToBandstop(z,p,k,Wc,BW); //frequency transformation in s-domain
ZeroPoleToTransferFun(num,den,z,p,k);
//Define the frequency grid (logarithmic)
FreqFr->Length = 1000;
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
}
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,BW;
double FS = 2;
int Order = 5; //design a fifth order filter.
IIRFilters.EllipticAnalog(Order,0.2,40,z,p,out k); //design analog protype
Wc = Math.Sqrt(0.2*0.6);
BW = 0.6 - 0.2;
LinearSystems.LowpassToBandstop(z,p,ref k,Wc,BW); //frequency transformation in s-domain
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
//Define the frequency grid (logarithmic)
FreqFr.Length = 1000;
SignalUtils.LogRamp(FreqFr,-1,1); //between 0.1 (=10^(-1)) and 10 (=10^1) rad/sec
SignalUtils.FrequencyResponseS(num,den,FreqFr,Response,0); //Laplace
TeeChart.DrawIt(Response,"Frequency response",false); //Y axis linear, X axis logarithmic
}
Declaration
Procedure LowpassToBandstop(z, p: TVec; var k: TSample; CenterFreq, Bw: TSample);
Description
Transform a lowpass filter prototype in zero-pole form to a bandstop filter, where the stopband has width BW centered around the frequency CenterFreq. Assumed sampling frequency is 2. The transformation is defined as ([1], p. 258):
s(Wu - Wl)
s --> -------------
s^2 + Wu*Wl
Wl - lower cutoff frequency
Wu - upper cutoff frequency
The routine also adds pairs of zeros at +/-j*CenterFreq, if the number of zeros is less then number of poles, to match the number of poles.