How to resolve the algorithm Apply a digital filter (direct form II transposed) step by step in the Objeck programming language
How to resolve the algorithm Apply a digital filter (direct form II transposed) step by step in the Objeck programming language
Table of Contents
Problem Statement
Digital filters are used to apply a mathematical operation to a sampled signal. One of the common formulations is the "direct form II transposed" which can represent both infinite impulse response (IIR) and finite impulse response (FIR) filters, as well as being more numerically stable than other forms. [1] Filter a signal using an order 3 low-pass Butterworth filter. The coefficients for the filter are a=[1.00000000, -2.77555756e-16, 3.33333333e-01, -1.85037171e-17] and b = [0.16666667, 0.5, 0.5, 0.16666667] The signal that needs filtering is the following vector: [-0.917843918645, 0.141984778794, 1.20536903482, 0.190286794412, -0.662370894973, -1.00700480494, -0.404707073677 ,0.800482325044, 0.743500089861, 1.01090520172, 0.741527555207, 0.277841675195, 0.400833448236, -0.2085993586, -0.172842103641, -0.134316096293, 0.0259303398477, 0.490105989562, 0.549391221511, 0.9047198589] [Wikipedia on Butterworth filters]
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Apply a digital filter (direct form II transposed) step by step in the Objeck programming language
Source code in the objeck programming language
class DigitalFilter {
function : Main(args : String[]) ~ Nil {
a := [1.00000000, -2.77555756e-16, 3.33333333e-01, -1.85037171e-17];
b := [0.16666667, 0.5, 0.5, 0.16666667];
signal := [-0.917843918645, 0.141984778794, 1.20536903482, 0.190286794412,
-0.662370894973, -1.00700480494, -0.404707073677, 0.800482325044,
0.743500089861, 1.01090520172, 0.741527555207, 0.277841675195,
0.400833448236, -0.2085993586, -0.172842103641, -0.134316096293,
0.0259303398477, 0.490105989562, 0.549391221511, 0.9047198589];
result := Filter(a, b, signal);
each(i : result) {
System.IO.Console->Print(result[i])->Print(((i + 1) % 5 <> 0) ? ",\t" : "\n");
};
}
function : Filter(a : Float[], b : Float[], signal : Float[]) ~ Float[] {
result := Float->New[signal->Size()];
each(i : signal) {
tmp := 0.0;
each(j : b) {
if(i-j >= 0) {
tmp += b[j] * signal[i - j];
};
};
each(j : a) {
if(i-j >= 0) {
tmp -= a[j] * result[i - j];
};
};
tmp /= a[0];
result[i] := tmp;
};
return result;
}
}
You may also check:How to resolve the algorithm Mertens function step by step in the Prolog programming language
You may also check:How to resolve the algorithm Walk a directory/Non-recursively step by step in the Elena programming language
You may also check:How to resolve the algorithm Truncatable primes step by step in the Factor programming language
You may also check:How to resolve the algorithm Guess the number step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Perfect totient numbers step by step in the D programming language