Sie sind auf Seite 1von 10

function[x]=t()

%generating data from the ideal filter for modeling function [a,b] = pade(p,q)
%2000 datas are used for designing %calculating filter coefficents by using pade's
x=zeros(1,100); approximation
for i=1:100 E=t();
x(1,i)=(sin((i-10)*pi/2)/((i-10)*pi)); x = E(:);
end if p+q>=length(x), error('Model order too large'), end
syms k X = convmm(x,p+1);
f=real(sin((k-10)*pi/2)/((k-10)*pi)); Xq = X(q+2:q+p+1,2:p+1);
x(1,10)=limit(f,k,10); a = [1;-Xq\X(q+2:q+p+1,1)];
end b = X(1:q+1,1:p+1)*a;
[h,w] = freqz(b,a,'whole',101);
function X = convmm(x,p) plot(w/pi,20*log10(abs(h)))
%it is used to generate a convolution matrix end
Y = length(x)+2*p-2;
x = x(:);
xpad = [zeros(p-1,1);x;zeros(p-1,1)]; function [a,b,err] = prony(p,q)
for i=1:p %calculating filter coeficients using prony method
X(:,i)=xpad(p-i+1:Y-i+1); k=t();
end x = k(:);
a.responses with unit of π for each filter of pade’s approximation N = length(x);
X = convmm(x,p+1);
Xq = X(q+1:Y+p-1,1:p);
a = [1;-Xq\X(q+2:N+p,1)];
b = X(1:q+1,1:p+1)*a;
err = x(q+2:N)'*X(q+2:N,1:p+1)*a;
[h,w] = freqz(b,a,'whole',2001);
plot(w/pi,20*log10(abs(h)))
end
The the above results is tell us the filter with ‘p=6’ and q=’13’is better than the rest of the others.
the delay is n0=10.
The coefficient of the better filters are as follows:
a𝑝 = [1.0000 − 1.0048 1.6165 − 1.1164 0.6713 − 0.2392 0.0433]
𝑏𝑞 = [0.035 − 0.0355 0.0117 0.0062 0.013 − 0.0217 − 0.0322 0.0464 0.1876 0.2834 0.2620 0.1585 0.0593 0.0107]

a) Now let us repeat part a) with the cut off frequency π/16(narrow band)
From the above results it seems the filter with ‘p=2’ and q=’17’is the best.
Note: we used the delay n0=10.
For the best filter we have the coefficients,𝑎𝑝 = [ 1.0000 − 1.9020 0.9191]
𝑏𝑞 = [ 0.0347 − 0.0262 0.0008 0.0008 0.0007 0.0006 0.0006 0.0005 0.0004 0.0004 0.000 0.0002
0.0002 0.0001 0.0001 0.0001 0.0000 0.0000]

In all cases the filters designed in part a) are better compared to these narrow band low pass filters.

b) Frequency responses with unit of π for each filter of prony method


Based on the above results we can conclude the filter with ‘p=4’ and ‘q=15’is the best.
Note: we used the delay n0=10.
This filter has an error of 4.9593*(10) ^-06 which is the lowest of all others .In all cases the prony method is better than the pade approximation. The
coefficients of this filter are 𝑝 = [1.0000 − 0.0000 1.3161 − 0.0000 0.3681] ,𝑏𝑞 = [ 0.0354 − 0.0000 0.0011 0.000 0.0168 − 0.0000 −
0.0391 0.0000 0.2021 0.5000 0.6982 0.6581 0.4300 0.1841 0.0412 0.0000]

c) Designing elliptic low pass filter.The following function is used for the design

function

[error] = ell(p,q)
%this function designs an eliptic low pass filter %n=10(order of 10),Rp=5,Rs=40 and normalized frequency of 0.5%cuttoff frequency pi/2 %it also calculates the
prony error
E=t();
x = Z(:);
Y = length(x);
X = convmm(x,p+1);
[b,a] = ellip(10,5,40,0.5);
freqz(b,a)
error = x(q+2:Y)'*X(q+2:Y,1:p+1)*a';
end
The error is 0.1971, even though the error is larger than that of the best filter in case c), the elliptic filter stops passing the signals
faster at the cutoff frequency compared to the best filter in case c).

Das könnte Ihnen auch gefallen