Digital Signal Processing Reference
In-Depth Information
function [h] = cascade2(a,b);
%
% cascade2
returns the convolution of FIR filters a and b.
%
The length of the new filter h is length(a) + length(b) - 1.
%
Used also for general multiplication of two polynomial functions
%
whose coefficients are placed consecutively in vectors a and b.
%
% Usage:
[h] = cascade2(a,b)
%
% Input:
a, filter coefficients
%
b, filter coeffieients
% Output:
h, cascaded filter coefficients
%
% Notes:
(1) Input vectors a and b must be 1xN (row) vectors
%
or Nx1 (column) vectors.
%
(2) If a and b are mixed column and row vectors they
%
are rearranged to be column vectors.
%
(3) Output vector h is Mx1 column vector
%
where M is length(a) + length(b) - 1.
%
[ra,ca] = size(a); if (ra == 1)&(ca > 1) a = a'; end
[rb,cb] = size(b); if (rb == 1)&(cb > 1) b = b'; end
[ra,ca] = size(a); [rb,cb] = size(b);
if ((ra > 1)&(ca == 1))&((rb > 1)&(cb == 1)) L1 = length(a) - 1; L2 = length(b) - 1;
Z = zeros(1,abs(L2-L1));
if L1 > L2
B = [b',Z]; A = a';
elseif L1 < L2
A = [a',Z]; B = b';
else
A = a; B = b;
end
L = L1+L2;
t(1:2*L+1) = 0;
for r = 1:floor(L/2)+1
for i = 1:r
t(r) = t(r) + A(i)*B(r - i + 1);
end
t(L - r + 2) = t(r);
end
h(1:L+1) = t(1:L+1);
else disp('Cascade2 warning: input must be single row or column vectors');
end
h = h';
return
Figure 2.22 Matlab
function to cascade two FIR filters.
2.8.1 Half-Band Low-Pass Filter
The half-band low-pass filter is used to reduce the number of sampled data points
to half its original size (i.e., decimation by 2). This is made simple by observing
that, apart from the central three coefficients, alternate coefficients are zero valued
 
Search WWH ::




Custom Search