Signal Processing Asked by RohitM on October 24, 2021
I am trying to convert filter realisation from Direct form 1 to cascade using function provided from Digital signal processing by Proakis. I designed lowpass IIR filter and extracted numerator and denominator coefficients. I used fvtool to plot pole zero as well as magnitude response. But when I use dir2cas function provided in textbook, matlab shows an error while plotting using fvtool. Can someone help?
The filter function:
filte = designfilt('lowpassiir','PassbandRipple',1,'StopbandAttenuation',30, ...
'PassbandFrequency', 3.4e3, 'StopbandFrequency', 4e3, ...
'SampleRate', 16e3);
sos = filte.Coefficients;
[b,a] = sos2tf(filte.Coefficients);
%fvtool(sos);
[b0, B0, A0] = dir2cas(b,a);
fvtool(B0,A0);
The direct to cascade function:
function [b0, B, A] = dir2cas(b,a);
b0 = b(1);
b = b/b0;
a0 = a(1);
a = a/a0;
b0 = b0/a0;
M = length(b);
N = length(a);
if N >M
b = [b zeros(1, N-M)];
elseif M > N
a = [a zeros(1, N-M)];
N = M;
else
NM = 0;
end
k = floor(N/2);
B = zeros(k,3);
A = zeros(k,3);
if k*2 == N;
b = [b 0];
a = [a 0];
end
broots = cplxpair(roots(b));
aroots = cplxpair(roots(a));
for i = 1:2:2*k
Brow = broots(i:1:i+1,:);
Brow = real(poly(Brow));
B(fix((i +1)/2),:) = Brow;
Arow = aroots(i:1:i+1,:);
Arow = real(poly(Arow));
A(fix((i+1)/2),:) = Arow;
end
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP