Overload List
| # | Signature | Description |
|---|---|---|
| 1 | void Bilinear(TMtx A, TVec B, TVec C, ref Double D, Double FS) | Apply bilinear transform to a linear system represented in state-space form. |
| 2 | void Bilinear(TVec z, TVec p, ref Double k, Double FS, Boolean AddZeros) | Result = bilinear transformation |
Overload 1: void Bilinear(TMtx A, TVec B, TVec C, ref Double D, Double FS)
Apply bilinear transform to a linear system represented in state-space form.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | A | TMtx | source TMtx |
| 2 | B | TVec | source TVec |
| 3 | C | TVec | source TVec |
| 4 | D | Double (ref) | output |
| 5 | FS | Double | scalar |
Result: stored in self (calling object)
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 b = new Vector(0);
Vector c = new Vector(0);
double k,Wc,d;
Matrix A = new Matrix(0,0);
double FS = 2;
int Order = 5; //design a fifth order filter.
IIRFilters.EllipticAnalog(Order,0.2,40,z,p,out k); //design analog protype
//passband ripple 0.2dB, stopband attenuation 40dB
LinearSystems.Bilinear(z,p,ref k,FS,true); //Sampling frequency = 2
Wc = 0.6; //request a cutoff at 0.6 Hz
LinearSystems.LowpassToLowpassZ(z,p,ref k,Wc, LinearSystems.BilinearUnwarp(1,FS)); //frequency transformation in z-domain
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
SignalUtils.FrequencyResponse(num, den, Response, 64, false, TSignalWindowType.wtRectangular, 0); //zero padding set to 64
MtxVecTee.DrawIt(Response, "Design method 0", false);
//Alternative 1:
IIRFilters.EllipticAnalog(Order,0.2,40,z,p,out k); //design analog protype
LinearSystems.Bilinear(z,p,ref k,FS,true); //Sampling frequency = 2
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
Wc = 0.6; //request a cutoff at 0.6 Hz
LinearSystems.LowpassToLowpassZ(num,den,Wc,LinearSystems.BilinearUnwarp(1,FS)); //frequency transformation in z-domain
SignalUtils.FrequencyResponse(num, den, Response, 64, false, TSignalWindowType.wtRectangular, 0); //zero padding set to 64
MtxVecTee.DrawIt(Response, "Design method 1", false);
//Alternative 2:
IIRFilters.EllipticAnalog(Order,0.2,40,z,p,out k); //design analog protype
Wc = LinearSystems.BilinearPrewarp(0.6,FS); //request a cutoff at 0.6 Hz
LinearSystems.LowpassToLowpass(z,p,ref k,Wc); //frequency transformation in s-domain
LinearSystems.Bilinear(z,p,ref k, FS,true); //Sampling frequency = 2
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
SignalUtils.FrequencyResponse(num, den, Response, 64, false, TSignalWindowType.wtRectangular, 0); //zero padding set to 64
MtxVecTee.DrawIt(Response, "Design method 2", false);
//Alternative 3:
IIRFilters.EllipticAnalog(Order,0.2,40,z,p,out k); //design analog protype
LinearSystems.ZeroPoleToStateSpace(A,b,c,out d,z,p,k);
Wc = LinearSystems.BilinearPrewarp(0.6,FS); //request a cutoff at 0.6 Hz
LinearSystems.LowpassToLowpass(A,b,c,ref d,Wc); //frequency transformation in s-domain
LinearSystems.Bilinear(A,b,c,ref d,2);
LinearSystems.StateSpaceToZeroPole(z,p,out k,A,b,c,d);
LinearSystems.ZeroPoleToTransferFun(num,den,z,p,k);
SignalUtils.FrequencyResponse(num,den,Response,64,false,TSignalWindowType.wtRectangular,0); //zero padding set to 64
MtxVecTee.DrawIt(Response,"Design method 3",false);
}
Overload 2: void Bilinear(TVec z, TVec p, ref Double k, Double FS, Boolean AddZeros)
Compute bilinear transformation.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | z | TVec | source TVec |
| 2 | p | TVec | source TVec |
| 3 | k | Double (ref) | output |
| 4 | FS | Double | scalar |
| 5 | AddZeros | Boolean |
Result: stored in self (calling object)
Apply bilinear transform to transfer function represented in zero-pole form. FS defines the sampling frequency. If z.Length < p.Length the routine will not add zeroes at -1 to match the number of poles unless AddZeros is True.
Bilinear transformation is defined with the mapping: s -> 2/T (1 - z^(-1))/(1 + z^(-1)), T = 1/FS Bilinear transform requires that the amplitude response of a continuous system is piecewise constant and can not be used to transform an analog differentiator to a digital filter (for example). Bilinear transform also does not preserve the impulse or the phase response [1].
References:
[1] Theory and application of digital signal processing, Lawrence R. Rabiner and Bernard Gold. Prentice-Hall, 1975