Transform the zeros and poles of a filter in s-domain to z-domain.
Transform the zeros Z and poles P of a filter from s-domain to z-domain, where FS is the sampling frequency. The transformation is defined as ([1], p. 224):
If the analog system has zeros with center frequencies greater then half the sampling frequency, their z-plane positions will be greatly aliased [1]. The transformation has the advantage of not affecting the phase response of the original transfer function.
Example 1
A bessel analog lowpass filter is converted to z-domain by using the matched Z transform. The analog filter has a normalized cutoff frequency at 1 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.
BesselAnalog(Order,z,p,k); //design analog protype
Wc := 0.5; //request a cutoff at 0.5 rad/sec
LowpassToLowpass(z,p,k,Wc);
MatchedZTransform(z,p,2); //Sampling frequency = 2
k := k/ComputeGain(z,p,1);
z.Size(p.Length,false);
z.SetVal(-1); //add missing zeros at -1
ZeroPoleToTransferFun(num,den,z,p,k);
FrequencyResponse(num,den,Response,64); //zero padding set to 64
DrawIt(20*Log10(Abs(Response)),'Magnitude');
DrawIt(PhaseSpectrum(Response)*(180/Pi),'Phase');
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.
BesselAnalog(Order,z,p,k); //design analog protype
Wc = 0.5; //request a cutoff at 0.5 rad/sec
LowpassToLowpass(z,p,k,Wc);
MatchedZTransform(z,p,2); //Sampling frequency = 2
k = k/ComputeGain(z,p,1);
z->Size(p->Length,false);
z->SetVal(-1); //add missing zeros at -1
ZeroPoleToTransferFun(num,den,z,p,k);
FrequencyResponse(num,den,Response,64); //zero padding set to 64
DrawIt(20*Log10(Abs(Response)),"Magnitude",false);
DrawIt(PhaseSpectrum(Response)*(180/PI),"Phase",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 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.BesselAnalog(Order,z,p,out k); //design analog protype
Wc = 0.5;
LinearSystems.LowpassToLowpass(z,p,ref k,Wc); //frequency transformation in s-domain
LinearSystems.MatchedZTransform(z, p, FS);
k = k/LinearSystems.ComputeGain(z,p,1);
z.Size(p.Length,false);
z.SetVal(-1); //add missing zeros at -1
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
SignalUtils.FrequencyResponse(num,den,Response,64,false,TSignalWindowType.wtRectangular,0); //zero padding set to 64
TeeChart.DrawIt(20*MtxExpr.Log10(MtxExpr.Abs(Response)),"Magnitude",false);
TeeChart.DrawIt(MtxExpr.PhaseSpectrum(Response)*(180/Math.PI),"Phase",false);
}