Overload List
| # | Signature | Description |
|---|---|---|
| 1 | void LowpassToBandpass(TMtx a, TVec b, TVec c, ref Double D, Double CenterFreq, Double BW) | Convert a lowpass filter prototype in state space form to a bandstop filter. |
| 2 | void LowpassToBandpass(TVec z, TVec p, ref Double k, Double CenterFreq, Double BW) | Frequency transformation from a lowpass to a bandpass filter in s-domain. |
Overload 1: void LowpassToBandpass(TMtx a, TVec b, TVec c, ref Double D, Double CenterFreq, Double BW)
Convert a lowpass filter prototype in state space form to a bandstop filter.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | a | TMtx | source TMtx |
| 2 | b | TVec | source TVec |
| 3 | c | TVec | source TVec |
| 4 | D | Double (ref) | output |
| 5 | CenterFreq | Double | scalar |
| 6 | BW | 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 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.LowpassToBandpass(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
MtxVecTee.DrawIt(Response,"Frequency response",false); //Y axis linear, X axis logarithmic
}
Overload 2: void LowpassToBandpass(TVec z, TVec p, ref Double k, Double CenterFreq, Double BW)
Frequency transformation from a lowpass to a bandpass filter in s-domain.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | z | TVec | source TVec |
| 2 | p | TVec | source TVec |
| 3 | k | Double (ref) | output |
| 4 | CenterFreq | Double | scalar |
| 5 | BW | Double | scalar |
Result: stored in self (calling object)
Transform a lowpass filter prototype in zero-pole form to bandpass filter, where the passband of width BW is centered around the frequency CenterFreq. Assumed sampling frequency is 2. The transformation is defined as ([1], p. 258): s -> (s^2 + W_u W_l)/(s (W_u - W_l))
Wl - lower cutoff frequency Wu - upper cutoff frequency
The routine also adds zeros at 0. It adds one zero, if the lowpass filter order is odd and already has zeros. If the filter does not have zeros, it adds sufficient zeros at 0 to match the order of the lowpass filter.
References:
[1] Theory and application of digital signal processing, Lawrence R. Rabiner and Bernard Gold. Prentice-Hall, 1975