Overload List
Overload 1: double ChebyshevIFilter(int Order, double PassRipple, const DewArray<double> &CutoffFreq, TFilterType FilterType, bool Analog, TVec *z, TVec *p, double &k, TIirFrequencyTransform IirFrequencyTransform = TIirFrequencyTransform::ftStateSpaceAnalog);
Design Chebyshev type I IIR filter.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Order | int | |
| 2 | PassRipple | double | |
| 3 | CutoffFreq | const DewArray<double> & | |
| 4 | FilterType | TFilterType | |
| 5 | Analog | bool | |
| 6 | z | TVec * | |
| 7 | p | TVec * | |
| 8 | k | double & | |
| 9 | IirFrequencyTransform = TIirFrequencyTransform::ftStateSpaceAnalog | TIirFrequencyTransform |
Design Chebyshev type I filter of Order with CutoffFreq frequencies and of FilterType type. Set Analog to True, to request and analog filter design in s-plane or set it to false to obtain a digital filter design in z-plane. PassRipple defines the passband ripple in dB. The CutoffFreq must be in range between 0 and 1 (Sampling frequency = 2) in case of a digital filter design.
IIrFrequencyTransform specifies when and how will the frequency band transformation be applied. The resulting transfer function is returned in the zero-pole form, with z,p,k variables.
#include "MtxExpr.h"
#include "Units.IIrFilters.h"
#include "Units.SignalUtils.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Signal;
using namespace Dew::Signal::Units::IIRFilters;
using namespace Dew::Signal::Units::SignalUtils;
void Example()
{
Vector z, p, num, den, FreqFr, Response;
int Order;
double k, Bw, Wc;
DewArray<double> WcArray; //modified 3dB frequency
WcArray.SetLength(2);
Order = ChebyshevIOrder(DewArray<double>{1, 2, 5, 7}, 0.2, 50, TFilterType::ftBandpass, WcArray, true);
ChebyshevIFilter(Order, 0.2, WcArray, TFilterType::ftBandpass, true, num, den);
FreqFr.Length = 1000; //Define the frequency grid (logarithmic)
LogRamp(FreqFr, -1, 1); //between 0.1 (=10^(-1)) and 10 (=10^1) rad/sec
FrequencyResponseS(num, den, FreqFr, Response); //Laplace
// Alternative: Design a digital filter with the passband between 0.2 and 0.5 Hz (FS =2)
// WcArray.SetLength(2);
// Order = ChebyshevIOrder(DewArray<double>{0.1, 0.2, 0.5, 0.6}, 0.2, 50, TFilterType::ftBandpass, WcArray, false);
// ChebyshevIFilter(Order, 0.2, WcArray, TFilterType::ftBandpass, false, num, den);
// FrequencyResponse(num, den, Response, 64);
// FreqFr.Size(Response.Length);
// FreqFr.Ramp(0, 1.0/FreqFr.Length);
}
Overload 2: double ChebyshevIFilter(int Order, double PassRipple, const DewArray<double> &CutoffFreq, TFilterType FilterType, bool Analog, TVec *Num, TVec *Den, TIirFrequencyTransform IirFrequencyTransform = TIirFrequencyTransform::ftStateSpaceAnalog);
The resulting transfer function is returned in the numerator/denumerator form with num and den.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Order | int | |
| 2 | PassRipple | double | |
| 3 | CutoffFreq | const DewArray<double> & | |
| 4 | FilterType | TFilterType | |
| 5 | Analog | bool | |
| 6 | Num | TVec * | |
| 7 | Den | TVec * | |
| 8 | IirFrequencyTransform = TIirFrequencyTransform::ftStateSpaceAnalog | TIirFrequencyTransform |
Overload 3: double ChebyshevIFilter(int Order, double PassRipple, const DewArray<double> &CutoffFreq, TFilterType FilterType, bool Analog, TVec *sos, TIirFrequencyTransform IirFrequencyTransform = TIirFrequencyTransform::ftStateSpaceAnalog);
The resulting transfer function is returned in the second order section form stored in the sos variable.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Order | int | |
| 2 | PassRipple | double | |
| 3 | CutoffFreq | const DewArray<double> & | |
| 4 | FilterType | TFilterType | |
| 5 | Analog | bool | |
| 6 | sos | TVec * | |
| 7 | IirFrequencyTransform = TIirFrequencyTransform::ftStateSpaceAnalog | TIirFrequencyTransform |
The sos variable can be passed directly to the IirInitBQ filter initialization routine. Second order section form delivers substantially higher numerical stability and range than filtering with num/den form which is used by the IirInit routine.
Overload 4: double ChebyshevIFilter(int Order, double PassRipple, const DewArray<double> &CutoffFreq, TFilterType FilterType, bool Analog, TMtx *A, TVec *B, TVec *C, double &d);
The resulting transfer function is returned in the state-space form with A,B,C,D variables.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Order | int | |
| 2 | PassRipple | double | |
| 3 | CutoffFreq | const DewArray<double> & | |
| 4 | FilterType | TFilterType | |
| 5 | Analog | bool | |
| 6 | A | TMtx * | |
| 7 | B | TVec * | |
| 8 | C | TVec * | |
| 9 | d | double & |
#include "MtxExpr.h"
#include "Units.IIrFilters.h"
#include "Units.SignalUtils.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Signal;
using namespace Dew::Signal::Units::IIRFilters;
using namespace Dew::Signal::Units::SignalUtils;
void Example()
{
Vector num(0);
Vector den(0);
Vector Response(0);
Vector FreqFr(0);
DewArray<double> WcArray(2);
//design analog filter
int Order = ChebyshevIOrder(DewArray<double>{1, 2, 5, 7}, 0.2, 50, TFilterType::ftBandpass, WcArray, true);
ChebyshevIFilter(Order, 0.2, WcArray, TFilterType::ftBandpass, true, num, den, TIirFrequencyTransform::ftStateSpaceAnalog); //design analog protype
FreqFr.Length = 1000;
LogRamp(FreqFr, -1, 1);
FrequencyResponseS(num, den, FreqFr, Response, 0);
//Alternative: Design a digital filter with the passband between 0.2 and 0.5 Hz (FS =2)
//Order = ChebyshevIOrder(DewArray<double>{0.1, 0.2, 0.5, 0.6}, 0.2, 50, TFilterType::ftBandpass, WcArray, false);
//ChebyshevIFilter(Order, 0.2, WcArray, TFilterType::ftBandpass, false, num, den, TIirFrequencyTransform::ftStateSpaceAnalog); //design digital protype
//FrequencyResponse(num,den,Response,64);
//FreqFr = Ramp(Response.Length, TMtxFloatPrecision::mvDouble, 0, 1.0 / Response.Length);
}