Apply a digital filter (direct form II transposed): Difference between revisions

Added MATLAB solution
(Go solution)
(Added MATLAB solution)
Line 451:
0.96185430, 0.69569009, 0.42435630, 0.19626223, -0.02783512
-0.21172192, -0.17474556, 0.06925841, 0.38544587, 0.65177084
</pre>
 
=={{header|MATLAB}}==
MATLAB is commonly used for filter design and implementation. To implement this filter, and display the original signal and the filtered result:
<lang MATLAB>
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];
a = [1.00000000, -2.77555756e-16, 3.33333333e-01, -1.85037171e-17];
b = [0.16666667, 0.5, 0.5, 0.16666667];
 
out = filter(b,a,signal)
 
figure
subplot(1,2,1)
stem(0:19, signal)
xlabel('n')
title('Original Signal')
 
subplot(1,2,2)
stem(0:19, out)
xlabel('n')
title('Filtered Signal')
</lang>
 
{{out}}
<pre>
out =
 
Columns 1 through 10
 
-0.1530 -0.4353 -0.1360 0.6975 0.6564 -0.4355 -1.0892 -0.5377 0.5170 1.0522
 
Columns 11 through 20
 
0.9619 0.6957 0.4244 0.1963 -0.0278 -0.2117 -0.1747 0.0693 0.3854 0.6518
</pre>
 
Anonymous user