Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
38 views5 pages

Notch Filter Design Assignment

This document presents the design of a notch filter using MATLAB code. It specifies the order, notch frequency, and notch width. It then finds the P matrix and q vector needed to solve for the filter coefficients by dividing the calculation into three parts. Finally, it plots the error convergence, impulse response coefficients, frequency response, and magnitude frequency response of the designed filter.

Uploaded by

Sohini Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views5 pages

Notch Filter Design Assignment

This document presents the design of a notch filter using MATLAB code. It specifies the order, notch frequency, and notch width. It then finds the P matrix and q vector needed to solve for the filter coefficients by dividing the calculation into three parts. Finally, it plots the error convergence, impulse response coefficients, frequency response, and magnitude frequency response of the designed filter.

Uploaded by

Sohini Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

PROGRAMMABLE AND EMBEDDED SYSTEMS ASSIGNMENT PART 1

NOTCH FILTER DESIGN

SOHINI ROY , 18IE33007

clear all
close all
clc

% Notch Filter Design


Fs=10e3; Ts=1/Fs;
% Specifing the order to be 128 :

M=128; % oder of filter


N=M+1; % number of filter coefficients

% Notch frequency
fo=1e03*Ts;
wo=2*pi*fo;

% Notch width
alpha=10*2*pi*Ts;

% Find the P matrix


dw = pi/500;
P=zeros(N);
q = zeros(N,1);
w = [0:dw:(wo-alpha/2)]';

% Part1

w=linspace(0,(wo-alpha/2),500)';
nM=[0:N-1]';
U=cos(nM*w'); % u vectors for every w between 0 to wo-alfa/2
for n1=1:N
for n2=1:N
P(n1,n2)=P(n1,n2)+trapz(U(n1,:).*U(n2,:));
end
end
q=q+-2*trapz(U,2);

% Part2
W=100; % weight of the notch part
dw = pi/500;
Epsi=0.001;
w=linspace((wo-alpha/2),(wo+alpha/2),200)';
nM=[0:N-1]';
U=cos(nM*w'); % u vectors for every w between 0 to wo-alfa/2
for n1=1:N
for n2=1:N
P(n1,n2)=P(n1,n2)+W*trapz(U(n1,:).*U(n2,:));
end

1
end
q = q-2*W*Epsi*trapz(U,2);

% Part3

w=linspace((wo+alpha/2),pi,500)';
dw=pi/400;
nM=[0:N-1]';
U=cos(nM*w'); % u vectors for every w between 0 to wo-alfa/2
for n1=1:N
for n2=1:N
P(n1,n2)=P(n1,n2)+trapz(U(n1,:).*U(n2,:));
end
q=q-2*trapz(U,2)*dw;
end

plot(q)
title("Error Convergence")

%%Solve for minimizing this : (a'P*a+q'*a+r)


a=-P\q;

%%Map back the coefficients


for k=1:M/2-1
h(M/2-k)=a(k+1)/2;
h(M/2+k)=a(k+1)/2;

2
end
h(M/2)=a(1);

stem(h)
title("Impulse Response Coefficients")

freqz(h)
title("Frequency Response")

3
F= linspace(0,Fs/2,2000);
H = freqz(h,1,F,Fs);
plot(F,abs(H))
title("Magnitude Frequency Response of Filter")

4
wo

wo = 0.6283

You might also like