Digital Signal Processing Reference
In-Depth Information
absdiff = abs(CCPrs(ctr)-conj(CCPrs(ctr+1:Lenx)));
y = find( absdiff < tol );
if isempty(y) % real number
temp = CCPrs(ctr); CCPrs(ctr:Lenx-1) = CCPrs(ctr+1:Lenx);
CCPrs(Lenx) = temp;
else; temp = CCPrs(ctr+1); CCPrs(ctr+1) = CCPrs(y(1)+ctr);
CCPrs(y(1)+ctr) = temp; end; end
To perform filtering using the Cascade Form filter coefficients, the input signal is filtered using
the first cascade filter section, the output of which is used as the input to the second cascade filter section,
and so on, until the signal has passed through all of the cascaded filter sections. The script
=
y
LV CascadeFormFilter(Bc,Ac,Gain,x)
works in this manner to filter the input vector x to produce the net filtered output y :
function [y] = LVCascadeFormFilter(Bc,Ac,Gain,x)
szA = size(Ac);
for ctr = 1:1:szA(1)
a = Ac(ctr,:); b = Bc(ctr,:);
x = filter(b,a,x);
end
y = Gain*x;
Example 2.44. Write a test script that will begin with a set of Direct Form filter coefficients, convert to
Cascade Form, filter a linear chirp first with the Direct Form coefficients, then (as a separate experiment),
filter a linear chirp using the Cascade Form coefficients, and plot the results from both experiments to
show that the results are identical.
[b,a] = butter(7,0.4),
x = chirp([0:1/1023:1],0,1,512);
y1 = filter(b,a,x);
[Bc,Ac,Gain] = LVDirToCascade(b,a),
[y2] = LVCascadeFormFilter(Bc,Ac,Gain,x);
figure(10); subplot(211); plot(y1);
subplot(212); plot(y2)
To convert from Cascade to Direct form, a script must separately convolve each of the numerator
factors and each of the denominator factors. Ac is a K by 3 matrix of biquad section denominator
coefficients, K being N/ 2 for even filter order N ,or (N
1 )/ 2 for odd filter order, Bc is an r by 3 matrix
of biquad section numerator coefficients, with r = floor (N/ 2 ) where N is the filter order .
function [b,a,k] = LVCas2Dir(Bc,Ac,Gain)
k = Gain; szB = size(Bc);
b = 1; for ctr = 1:1:szB(1),
b = conv(b,Bc(ctr,:)); end;
szA = size(Ac);a=1;
for ctr = 1:1:szA(1),
a = conv(a,Ac(ctr,:)); end
+
Search WWH ::




Custom Search