Design of a Tunable FIR Filter

Status
Not open for further replies.

KhaledOsmani

Full Member level 6
Joined
May 4, 2014
Messages
384
Helped
1
Reputation
2
Reaction score
1
Trophy points
18
Activity points
3,933
Hello,

please check the following code:
Code:
%Illustration of tunable FIR Filter
clf;
clc;
close all;
w = 0:pi/255:pi;
f = [ 0 0.36 0.46 1];
m = [1 1 0 0];
b1 = remez(50, f, m);
h1 = freqz(b1,1,w);
m1 = 20*log10(abs(h1));
n = -25:-1;
c = b1(1:25)./sin(0.41*pi*n);
wc = ]0.31*pi 0.51*pi];
for i = 1:2
    d = c.*sin(wc(i)*n);
    q = (b1(26)*wc(i))/(0.4*pi);
    b2 = [d q fliplr(d)];
    mag(i,:) = 20*log10(abs(freqz(b2,1,w)));
end
plot (w/pi,mag(1,:) , 'b--', w/pi,m1, 'r-', w/pi, mag(2,:), 'g-');
grid;
axis([ 0 1 -80 5]);
xlabel('\omega/\pi');
ylabel('Gain, dB');
legend ('\omega_{c} = 0.31 \pi','\omega_{c} = 0.41/pi ' , '\omega_{c} = 0.51 \pi')

What type of filter is being designed as the nominal filter by the above code? what are its specifications? what is the order of the filter?
what are the cutoff frequencies of the filters being designed?
How to modify the above code so I can be able to determine and plot the gain response of the delay complementary filter of each of the filters being designed in it?
 
Last edited by a moderator:

Please see the help of the remez function (doc remez).

Z
 

zorro gave the answer. The complete filter specification is in this three lines:
Code:
f = [ 0 0.36 0.46 1];
m = [1 1 0 0];
b1 = remez(50, f, m);

If you are using a recent Matlab version, consider this:
The remez function has been replaced by the new firpm function.
 

HOW TO modify it to determine and plot the gain response of the delay complementary filter of each of the filters being designed in it?
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…