Design low pass filter with a given transfer function

3 次查看(过去 30 天)
I must design a low-pass filter with a given transfer function in z-domain:
H(z) = (1-z^(-6))^2 / (1-z^(-1))^2
Considering the x signal (1x2000) I want to filter, i wrote
N = 2000;
h1 = zeros(1,N);
%
% a. Low-Pass Filter
for i = 1:N
if (i == 1)
h1(1) = 1;
a1(1) = 1;
b1(1) = 1;
else
if (i == 2)
h1(2) = 1/(1-2*x(1));
b1(2) = 1;
a1(2) = 1-2*x(1);
else
if ((i == 3) || (i == 4) || (i == 5) || (i == 6))
h1(i) = 1/(1+x(i-2)-2*(x(i-1)));
b1(i) = 1;
a1(i) = (1+x(i-2)-2*(x(i-1)));
else
if ((i == 7) || (i == 8) || (i == 9) || (i == 10) || (i == 11) || (i == 12))
h1(i) = ((1-2*x(i-6)))/(1+(x(i-2))-2*(x(i-1)));
b1(i) = (1-2*x(i-6));
a1(i) = (1+(x(i-2))-2*(x(i-1)));
else
h1(i) = ((1+(x(i-12))-2*(x(i-6))))/(1+(x(i-2))-2*x(i-1));
b1(i) = ((1+(x(i-12))-2*(x(i-6))));
a1(i) = (1+(x(i-2))-2*x(i-1));
end
end
end
end
end
figure,
freqz(b1,a1,512,fc);
y = filter(b1,a1,x);
Is it correct? I don't think so because the plot it is a mess and definitively not a low-pass! What is it wrong?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Digital Filter Analysis 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by