0% found this document useful (0 votes)
32 views26 pages

Share Twinklepradhanss

The document is a lab record for a Signals and Systems course, detailing experiments conducted by a student named Twinkle Pradhan. It includes aims, theories, MATLAB codes, and conclusions for various experiments related to Discrete Fourier Transform (DFT), Inverse Discrete Fourier Transform (IDFT), and properties of DFT. Each experiment is organized with an index, and the document concludes with the student's submission details.

Uploaded by

atifroy888999
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)
32 views26 pages

Share Twinklepradhanss

The document is a lab record for a Signals and Systems course, detailing experiments conducted by a student named Twinkle Pradhan. It includes aims, theories, MATLAB codes, and conclusions for various experiments related to Discrete Fourier Transform (DFT), Inverse Discrete Fourier Transform (IDFT), and properties of DFT. Each experiment is organized with an index, and the document concludes with the student's submission details.

Uploaded by

atifroy888999
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/ 26

Department of Electrical & Electronics Engineering

SIGNAL & SYSTEMS LAB – II

LAB RECORD

Name: Twinkle Pradhan

Year: 3rd Year Semester: 6th i

Regd.No.: 2202060021 i

Section: EEE-1 i

1
INDEX
S.N. Name of the Page Date of Date of Remarks
Experiment
No. Experiment Submission

Computation of Discrete
1 Fourier Transform (DFT) 3–5 08-01-2025 22-01-2025
using MATLAB

Computation of Inverse
Discrete Fourier 15-01-2025 22-01-2025
2 6– 9
Transform (IDFT) using
MATLAB

To prove the general


properties of discrete
Fourier Transform (DFT)
using MATLAB
3 10–16 29-01-2025 05-02-2025
(a) Linearity
(b) Circular Time
Shift
(c) Circular
Frequency Shift

To prove the n-point


circular convolution
property of the DFT using 05-02-2025 12-02-2025
4 17 - 19
MATLAB.

Design second order


Infinite Impulse Response
(IIR) filter using various 12-02-2025 19-03-2025
5 20 –23
transformation methoed
and plot their magnitude
response.

Design of Finite Impulse


Response (FIR) low pass
6 and high pass filter and 24 –26 19-03-2025 26-03-2025
plot the gain response
using MATLAB

2
EXPERIMENT-01

AIM OF THE EXPERIMENT:


Computation of Discrete Fourier Transform (DFT) using MATLAB.

SOFTWARE USED:
MATLAB R2024b

THEORY:
DFT is defined only for sequences of finite length, DFT is obtained by sampling one period of
the FT at a finite number of frequency points. DFT plays important role in the implementation
of many signal processing algorithms. DFT is goods used to perform linear filtering operations
in frequency domain.

DTFT of a sequence is periodic. There are infinitely many w in this range. If we use a digital
computer to compute N equally spaced points over the interval 0<w≤2pi, then the N points
should be located at

ωk = k, k = 0,1, . . . . . , N − 1
N
The N equally spaced frequency samples of the DTFT are known as the DFT denoted by X(k)

X(k) = X(𝑒 −𝑗𝜔 ) at ω = k, k = 0,1, . . . . . , N − 1
N
For only L>N – signal can be recovered

N−1

X(k) = ∑ x(n)𝑒 −𝑗2𝜋𝑘𝑛/𝑁 0 ≤ k ≤ N − 1


n=0

Here,
n= Time index
k= frequency index/ discrete frequency

MATLAB CODE:

%Function for DFT


function [Xk,k,n,x1]=dft(x,N)
x1=zeros(1,N);
x1(1:length(x))=x;
n=0:1:N-1;
k=0:1:N-1;
nk =n.*k;

3
wn=exp (-1i*2*pi/N);
Wn=wn.^(nk);
Xk=x1.*Wn;
end
%Program for DFT
clc;
clear all;
close all;
x=[1 5 1 3 0 4 9 2 8 1 5 4 3 2 3];
N=length(x);
[Xk,k,n,x1]=DFTfunc(x,N);
subplot(2,1,1);
stem(n,x1),
grid on
title('Input');
xlabel('TIME');
ylabel('AMPLITUDE'),
xlim([-1 15]);
ylim([-1 15]);
subplot(2,1,2);
stem(n,Xk);
grid on
title('DFT of Input');
xlabel('TIME');
ylabel('AMPLITUDE');
xlim([-1 17]);
ylim([-1 17]);

4
OUTPUT WAVEFORMS:

Plot of Input and DFT of Input Sequence

CONCLUSION:
From the above experiment, we generated the DFT of the Input Sequence using MATLAB.

SUBMITTED BY:
Twinkle Pradhan
2202060021

5
EXPERIMENT-02

AIM OF THE EXPERIMENT:


Computation of Inverse Discrete Fourier Transform (IDFT) using MATLAB.

SOFTWARE USED:
MATLAB R2024b

THEORY:
2𝜋𝑘
When we sample x(ω) at equally spaced frequencies ωk = where N ≥ 1, the resultant
𝑁
samples are

N−1

X(k) = ∑ x(n)𝑒 −𝑗2𝜋𝑘𝑛/𝑁 0 ≤ k ≤ N − 1


n=0

The relation in the above is the formula for transforming a sequence [x(n)] of length L ≥ N
into a sequence of frequency samples [x(k)] of length N. Since the frequency samples are
obtained by evaluating the Fourier transform x(ω) at a set of N (equally spaced) discrete
frequencies, the relation is called the discrete Fourier transform (DFT) of x(n) In turn, the
relation given allows us to recover the sequence x(n) from the frequencies samples.

N−1
1
X(k) = ∑ X(k)𝑒 −𝑗2𝜋𝑘𝑛/𝑁 0 ≤ k ≤ N − 1
N
n=0

when x(n) has length L<N, the N-point yields x(n)=0 for L ≤ n ≤ (N-1)
Here,
N= no. of sampling point
L= length of the sequence
n= time variable in time domain
k= time variable in frequency domain

MATLAB CODE:
clc;
clear all;
close all;
% Define input sequence
x = [2 0 8 1 7 10 3 1 9 1 1 5 6 9];
N = length(x);

6
% Compute DFT and IDFT
[xk, k, xN, n] = DFTfunc(x, N);
[Xn, n] = IDFTfunc(N, xk);
% Plot input sequence
subplot(3, 1, 1);
stem(n, xN, 'filled');
grid on;
title('Plot of Input Sequence x(n)');
xlabel('n ----->');
ylabel('Amplitude');
xlim([-1 10]);
ylim([-1 11]);
% Plot DFT sequence (Real and Imaginary parts)
subplot(3, 1, 2);
stem(n, real(xk), 'filled'); % Real part of DFT
hold on;
stem(n, imag(xk), 'r'); % Imaginary part of DFT
grid on;
title('Plot of DFT Sequence X(k)');
xlabel('k ----->');
ylabel('Amplitude');
legend('Real Part', 'Imaginary Part');
xlim([-1 10]);
% Plot IDFT sequence
subplot(3, 1, 3);
stem(n, real(Xn), 'filled');
grid on;
title('Plot of IDFT of DFT Sequence');
xlabel('n ----->');
ylabel('Amplitude');

7
xlim([-1 10]);
ylim([-1 11]);
% Function to compute DFT
function [xk, k, xN, n] = DFTfunc(x, N)
xN = zeros(1, N);
xN(1:length(x)) = x;
n = 0:N-1;
k = 0:N-1;
W = exp(-1i * 2 * pi / N);
Wnk = W .^ (n' * k);
xk = xN * Wnk; % Compute DFT
end
% Function to compute IDFT
function [Xn, n] = IDFTfunc(N, xk)
n = 0:N-1;
k = 0:N-1;
W = exp(1i * 2 * pi / N);
Wnk = W .^ (k' * n);
Xn = (1/N) * (xk * Wnk);
end

8
OUTPUT WAVEFORMS:

Plot of Input, DFT and IDFT of Input Sequence

CONCLUSION:
From the above experiment, we generated the DFT and IDFT of the Input Sequence using
MATLAB.

SUBMITTED BY:
Twinkle Pradhan
2202060021

9
EXPERIMENT-03

AIM OF THE EXPERIMENT:


To prove the general properties of Discrete Fourier Transform using MATLAB.
a) Linearity
b) Circular Time Shift
c) Circular Frequency Shift

SOFTWARE USED:
MATLAB R2024b

THEORY:
LINEARITY
Linearity Property of DFT states that the DFT of the linear combination pf two or more signals
is the sum of the linear combination of DFT of individual signals.
𝐼𝑓 𝑥(𝑛) ⇔ 𝑋(𝑘)
𝑦 (𝑛 ) ⇔ 𝑌 (𝑘 )
Then for any real valued or complex valued constant a and b,
𝑎𝑥 (𝑛) + 𝑏𝑦(𝑛) ⇔ 𝑎𝑋(𝑘) + 𝑏𝑌(𝑘)

The proof for linearity property is as follows,


𝑁−1
𝑋1 (𝐾 ) = 𝐷𝐹𝑇{𝑥1 (𝑛)} = ∑ 𝑥1 (𝑛)𝑒 −𝑗2𝜋𝑘𝑛/𝑁
𝑛=0
𝑁−1
𝑋2 (𝐾 ) = 𝐷𝐹𝑇{𝑥2 (𝑛)} = ∑ 𝑥2 (𝑛)𝑒 −𝑗2𝜋𝑘𝑛/𝑁
𝑛=0
𝑁−1
𝐷𝐹𝑇{𝑎1 𝑥1 (𝑛) + 𝑎2 𝑥2 (𝑛)} = ∑ {𝑎1 𝑥1 (𝑛) + 𝑎2 𝑥2 (𝑛)}𝑒 −𝑗2𝜋𝑘𝑛/𝑁
𝑛=0
𝑁−1
= ∑ {𝑎1 𝑥1 (𝑛)}𝑒 −𝑗2𝜋𝑘𝑛/𝑁 + {𝑎2 𝑥2 (𝑛)}𝑒 −𝑗2𝜋𝑘𝑛/𝑁
𝑛=0
𝑁−1 𝑁−1
= 𝑎1 ∑ {𝑥1 (𝑛)}𝑒 −𝑗2𝜋𝑘𝑛/𝑁 + 𝑎2 ∑ {𝑥2 (𝑛)}𝑒 −𝑗2𝜋𝑘𝑛/𝑁 = 𝑎1 𝑋1 (𝑘) + 𝑎2 𝑋2 (𝑘)
𝑛=0 𝑛=0

TIME SHIFT
A shift in time corresponds to a phase shift that is linear in frequency. Because of the periodicity
induced by the DFT and IDFT, the shift is circular of modulus N samples.

Given an N-point signal {X[n], n 𝜖 ZN}, the signal g[n] = x[(n-m) N] represents a circular shift
of x[n] by m samples to the right if by DFT, 𝑥(𝑛) ⇔ 𝑋 (𝑘) then by time shifting property of
DFT,
𝑋((𝑛 − 1))𝑁 ⇔ 𝑋(𝑘)𝑒 −𝑗𝜋𝑘𝑙/𝑁

The proof for time shift property is as follows,


𝑁−1
𝐷𝐹𝑇{𝑥(𝑛 − 𝑚)𝑁 } = ∑ 𝑥(𝑛 − 𝑚)𝑁 𝑒 −𝑗2𝜋𝑘𝑛/𝑁
𝑛=0

10
Let p = (n-m), n = (m+p)
𝑁−1
𝐷𝐹𝑇{𝑥(𝑛 − 𝑚)𝑁 } = ∑ 𝑥(𝑝) 𝑒 −𝑗2𝜋𝑘(𝑚+𝑝)/𝑁
𝑝=0
𝑁−1
= ∑ 𝑥(𝑝) 𝑒 −𝑗2𝜋𝑘(𝑚)/𝑁 𝑒 −𝑗2𝜋𝑘(𝑝)/𝑁
𝑝=0
𝑁−1
= 𝑒 −𝑗2𝜋𝑘(𝑚)/𝑁 ∑ 𝑥(𝑝) 𝑒 −𝑗2𝜋𝑘(𝑝)/𝑁
𝑝=0
= 𝑒 −𝑗2𝜋𝑘(𝑚)/𝑁 . 𝑋(𝑘)

FREQUENCY SHIFT
The circular frequency shift property of the DFT states that shifting the time domain signal by
n samples will result in a corresponding phase shift in the frequency domain. The property is
represented mathematically as
𝑋 [𝑘 − 𝐿] = 𝑋 [𝑁 + 𝐾 − 𝐿] 𝑥(𝑛) 𝑒 𝑗2𝜋/𝑁
Where X[k – L] is the DFT of the time domain signal x[n], N is the number of samples and j
is the imaginary unit.

This property allows for efficient implementation of time-domain shifts in the frequency
domain, as the calculation of the DFT of the shifted signal is reduced to simple phase
adjustments of the existing DFT coefficients.

The proof for frequency shift is as follows,


𝑁−1
𝐷𝐹𝑇{𝑥(𝑛)𝑒 𝑗2𝜋𝑚𝑛/𝑁 } = ∑ 𝑥(𝑛) 𝑒 −𝑗2𝜋𝑘𝑛/𝑁 𝑒 𝑗2𝜋𝑚𝑛/𝑁
𝑝=0
𝑁−1
= ∑ 𝑥(𝑛) 𝑒 −𝑗2𝜋(𝑘−𝑚)𝑛/𝑁
𝑝=0
𝑁−1
= ∑ 𝑥(𝑛) 𝑒 −𝑗2𝜋(𝑘−𝑚)𝑛/𝑁
𝑝=0
= 𝑋(𝐾 − 𝑚)𝑁

MATLAB CODE:
LINEARITY
% Function for DFT
function [Xk, k, Xn, n] = DFTfunc(x, N)
L = length(x);
if N < L
error('N must be greater than or equal to length of x');
end

Xn = zeros(1, N);
Xn(1:L) = x; % Assign input values
n = 0:N-1;
k = 0:N-1;
% Compute DFT using matrix multiplication

11
Wn = exp(-1i * 2 * pi / N * (n' * k));
Xk = Xn * Wn;
end
clc;
clear all;
close all;
% Input sequences
x = [4 1 0 5 -3 -5];
y = [-5 4 -4 0 -3 2];
b = 2;
a = 5;
f = a * x + b * y;
% Compute DFTs
[Xk, kx, nx, x1] = DFTfunc(x, 6);
[Yk, ky, ny, yl] = DFTfunc(y, 6);
aXk_bYk = a * Xk + b * Yk;
% Compute DFT of summed sequence
[Fk, kf, nf, fl] = DFTfunc(f, 6);
% Plot DFT of individual sequences with coefficients
subplot(2, 1, 1);
stem(kx, abs(aXk_bYk), 'filled');
grid on;
title("Plot of aX(k) + bY(k)");
xlabel('k --->');
ylabel('Amplitude --->');
% Plot DFT of summed sequence
subplot(2, 1, 2);
stem(kf, abs(Fk), 'filled');
grid on;
title("Plot of DFT [ax(n) + by(n)]");
xlabel('k ----->');
ylabel('Amplitude --->');
% Plot input sequences
figure;
stem(x, 'b', 'filled'); hold on;
stem(y, 'r', 'filled'); hold off;
legend('Seq x(n)', 'Seq y(n)');
title("Plot of Two Input Sequences");
xlabel('n ------>');
ylabel('Amplitude ----->');

12
CIRCULAR TIME SHIFT
clc;
clear all;
x = [0 2 4 6 8 10 12 14 16 18];
N = length(x) - 1;
n = 0:N;
y = circshift(x, [0, 4]);
subplot(3, 2, 1);
stem(n, x);
title('Original signal');
xlabel('n ---->');
ylabel('AMPLITUDE ---->');
xlim([0 10]); % Adjust x-axis limit
ylim([0 20]); % Adjust y-axis limit
hold on;
subplot(3, 2, 2);
stem(n, y);
title('Shifted signal');
xlabel('n ---->');
ylabel('AMPLITUDE ---->');
xlim([0 10]);
ylim([0 20]);
hold on;
X1 = fft(x);
Y1 = fft(y);
subplot(3, 2, 3);
stem(n, angle(X1));
title('Phase of Original Signal');
xlabel('k ---->');
ylabel('Phase ---->');
xlim([-2 12]); % Adjust x-axis limit
ylim([-pi pi]); % Adjust y-axis limit
hold on;
subplot(3, 2, 4);
stem(n, angle(Y1));
title('Phase of Shifted Signal');
xlabel('k ---->');
ylabel('Phase ---->');
xlim([-2 12]);% Adjust y-axis limit
ylim([-pi pi]);% Adjust y-axis limit
hold on;
subplot(3, 2, 5);
stem(n, abs(X1));
title('Magnitude of Original Signal');
xlabel('k ---->');
ylabel('Magnitude ---->');
xlim([1 8]); % Adjust x-axis limit
ylim([0 100]); % Adjust y-axis limit
hold on;
subplot(3, 2, 6);

13
stem(n, abs(Y1));
title('Magnitude of Shifted Signal');
xlabel('k ---->');
ylabel('Magnitude ---->');
xlim([1 8]);% Adjust x-axis limit
ylim([0 100]);% Adjust y-axis limit
hold on;

% User-defined function to calculate DFT


function X = fft(x)
N = length(x);
X = zeros(1, N);
for k = 1:N
X(k) = 0;
for n = 1:N
X(k) = X(k) + x(n) * exp(-1i * 2 * pi * (k - 1) * (n - 1) / N);
end
end
end

CIRCULAR FREQUENCY SHIFT


clc;
clear all;
close all;

% Input signal
a = [1, 3, 5, 7 , 9];
L = length(a);
k = 0:L-1;
N = 0:L-1;

% Compute DFT matrix


Wn = exp(-1i * 2 * pi / L);
M = N' .* k; % Element-wise multiplication for exponent
W = Wn .^ M; % Correct DFT computation

% Compute DFT
X = a * W;
p = 4;
W2 = exp(1i * 2 * pi / L);
W1 = W2 .^ (p * k); % Frequency shift factor
X1 = X .* W1; % Apply shift in frequency domain

% Plot input signal


subplot(3,1,1);
stem(N, a, 'filled');
grid on;
title('Plot of Input Signal');
xlabel('n (Discrete Time Index)');

14
ylabel('Amplitude');
% Plot original DFT
subplot(3,1,2);
stem(k, abs(X), 'filled');
grid on;
title('Plot of DFT (without any shift)');
xlabel('k (Number of samples)');
ylabel('|X(k)| (Magnitude)');
% Plot DFT after circular shift
subplot(3,1,3);
stem(k, abs(X1), 'filled');
grid on;
title('Plot of X(K) (Shifting by 2 Places)');
xlabel('k (Number of samples)');
ylabel('|X(k-2)| (Magnitude)');

OUTPUT WAVEFORMS:

(a) Plot of Input and Output (Linearity Property)

15
(b) Plot of Input and Output (Circular Time Shift Property)

(c) Plot of Input and Output (Circular Frequency Shift Property)


CONCLUSION:
In this experiment, the general properties of Discrete Fourier Transform such as linearity,
circular time shift and circular frequency shift were verified.

SUBMITTED BY:
Twinkle Pradhan
2202060021

16
EXPERIMENT-04

AIM OF THE EXPERIMENT:


To prove the n-point circular convolution property of the DFT using MATLAB.

SOFTWARE USED:
MATLAB R2024b

THEORY:
The n-point circular convolution property of the Discrete Fourier transform (DFT) states that
the DFT of the the circular convolution of two sequences is equal to the element wise product
of their DFTs. This property allows us to perform convolution operations in the frequency
domain, which is often more computationally efficient than in time domain. The circular
convolution of two sequences, denoted as "" operator, is defined as the periodic extension of
the convolution of the two sequences in the time domain. The property holds true for my finite
length sequences, if the length of the DFT is equal to the length of the sequences.
𝐿𝑒𝑡 𝑥(𝑛) ⇔ 𝑋 (𝑘)
𝑦 (𝑛 ) ⇔ 𝑌 (𝑘 )

𝑥3 = 𝑥1 (𝑛) Ⓧ 𝑥2 (𝑛)
𝑁−1
𝑥3 = ∑ 𝑥(𝑚)𝑦(𝑛 − 𝑚)
𝑚=0

where 𝑥3 represents the circular convolution.

The proof for n-point circular convolution is as follows,


-j2πkn/ Ν
Χ₁(Κ) = ∑𝑁−1
𝑛=0 x₁(n) e = ∑𝑁−1
𝑚=0 x₁(m) e
-j2πkm/N
[n=m]
𝑁−1 Ν 𝑁−1
Χ2(Κ) = 𝑛=0 x2(n) e
∑ -j2πkn/ ∑
= 𝑝=0 x2(p) e -j2πkp/N
[n=p]

Consider the Product of X₁(K) X₂(K). The inverse DFT of the product is given by,
j2πkn/ Ν
DFT -¹[X₁(K) X₂(K)] = 1/Ν ∑𝑁−1𝑘=0 Χ₁(K)X2(K) e
Substituting the value of the first 2 equations in the current equation,
-j2πkm/ Ν ∑𝑁−1
DFT -1[X₁(K) X₂(K)] = 1/N ∑𝑁−1 𝑁−1
𝑛=0 [∑𝑚=0 x₁(m) e ] [ 𝑝=0 x₁(m) e-j2πkp/N] ej2πkn/ Ν
𝑁−1 j2πk(n-m-p)/ Ν
DFT-1[X₁(Κ) Χ₂(K)] = 1/N [∑𝑁−1 𝑁−1
𝑛=0 x(m)][ ∑𝑝=0 x2(p)][ ∑𝑘=0 e ]

Let (n-m-p) = qN and q is an integer


∑𝑁−1 j2πk(n-m-p)/ Ν j2πkqN/ Ν j2πkq (j2πq)^k
𝑘=0 e = ∑𝑁−1
𝑘=0 e = ∑𝑁−1
𝑘=0 e = ∑𝑁−1
𝑘=0 e = ∑𝑁−1 k
𝑘=0 (1) = N

∑𝑁−1 𝑁−1 𝑁−1 𝑁−1


𝑝=0 x2(p) = ∑𝑚=0 x2 (n-m-qN) = ∑𝑚=0 x2 (n – m, mod N) = ∑𝑚=0 x2(p) =
∑𝑁−1
𝑚=0 x2((n-m))n

DFT -1[X₁(K) X₂(K)] = 1/Ν [∑𝑁−1 𝑁−1


𝑚=0 x1(m)][ ∑𝑚=0 x2((n-m))N]
DFT -1[X₁(K) X₂(K)] = ∑𝑁−1
𝑚=0 x1(m) x2((n-m))N

17
DFT -1[X₁(K) X₂(K)] = 𝑥1 (𝑛) Ⓧ 𝑥2 (𝑛)
[X₁(K) X₂(K)] = DFT [𝑥1 (𝑛) Ⓧ 𝑥2 (𝑛)]
MATLAB CODE:
clc;
x=[2 -1 1 -1];
y=[4 3 2 1];
L=length(x);
k=0:L-1;
N=0:L-1;
wn=exp(-1i*2*pi/L);
m=N'*k;
w=wn.^m;
X=x*w;
Y=y*w;

%figure (1)
subplot (2,2,1)
stem(N,x);
title('Plot of Input Signal x(n)');
xlabel('n(Discrete Time Index)');
ylabel('x(n) Amplitude');
subplot(2,2,2);
stem(N,y);
title('Plot of Input Signal y(n)');
xlabel('n(Discrete Time Index)');
ylabel('y(n) Amplitude');

%figure (2)
subplot (2,2,3)
z1=cconv(x,y,L);
stem(k,z1);
title('Plot of x(n)');
xlabel('k(no. of samples)');
ylabel('X(k) Magnitude');

subplot(2,2,4)
z=X.*Y;
I=ifft(z);
stem(k,I);
title('Plot of IDFT OF [X(k)*Y(k)]');
xlabel('k(no. of samples)');
ylabel('X(k) Magnitude');

18
OUTPUT WAVEFORMS:

Plot of Input and Output Waveforms


CONCLUSION:
In this experiment, the n-point circular convolution property of the Discrete Fourier Transform
using MATLAB was verified.

SUBMITTED BY:
Twinkle Pradhan
2202060021

19
EXPERIMENT-05

AIM OF THE EXPERIMENT:


Design second order Infinite Impulse Response (IIR) filter using various transformation
methoed and plot their magnitude response.

SOFTWARE USED:
MATLAB R2024b

THEORY:

 IIR filters are of recursive type, whereby the present output sample depends on the
present input, past input sample and output samples.
 For IIR filters to be realizable and stable,

h(n) = 0 for n<0


∑ ‖ℎ(𝑛)‖ < ∞
𝑛=0

 IIR filters have the transfer function of the form

∑𝑀 𝑏𝑘 𝑧 −𝑘
H(z)= ∑∞
𝑛=0 ℎ (𝑛 )𝑧
−𝑛
= 1+∑𝐾=0
𝑀 −𝑘
𝐾=1 𝑎𝑘 𝑧

 The design of IIR filter for given specifications is to find filter coefficients 𝑎𝑘 S and
𝑏𝑘 S.

Analog L.P.F

The magnitude function of the Butterworth LPF is given by


1
𝐻 (𝑗Ω) = Ω
1 ,N= 1,2,3,…….
[1+( )2𝑁]2
Ω𝑐

Where N=order of the filter

Ωc=cut off frequency

The function is monotonically decreasing where maximum response is unity at 0.

At Ω=Ωc, the curve pass through 0.707 which corresponds to -3db point.
20
Analog H.P.F

The magnitude function of the Butterworth HPF is given by


1
𝐻 (𝑗Ω) = Ω
1 ,N= 1,2,3,…….
[1+( )2𝑁]2
Ω𝑐

Band pass filter

This filter allows specified band of frequency and attenuates all other frequencies that ranges
from lower cut off frequency to higher cut off frequency.

Specification needed to design a filter-

 Pass band attenuation (Rp)


 Stop band attenuation (Rs)
 Pass band cut off frequency (ωp)
 Stop band cut off frequency (ωs)
 Sampling frequency

MATLAB CODE:
clc;
clear all;
close all;
wc = 1;
Q = 1;
% Analog filter transfer function: H(s) = wc^2 / (s^2 + wc/Q * s + wc^2)
b_analog = [wc^2];
a_analog = [1, wc/Q, wc^2];

% Sampling settings
Fs = 10;
Ts = 1 / Fs;
% 1. Bilinear Transformation
[b_bilinear, a_bilinear] = bilinear(b_analog, a_analog, Fs);
% 2. Impulse Invariant Transformation
[b_impulse, a_impulse] = impinvar(b_analog, a_analog, Fs);
% 3. Matched Z-Transformation (Pole-zero mapping method)
Hs = tf(b_analog, a_analog);
Hz_matched = c2d(Hs, Ts, 'matched');
[b_matched, a_matched] = tfdata(Hz_matched, 'v');
% Frequency response setup
f = linspace(0, Fs/2, 500);
omega = 2 * pi * f / Fs;
% Frequency responses
H_bilinear = freqz(b_bilinear, a_bilinear, omega);
H_impulse = freqz(b_impulse, a_impulse, omega);
21
H_matched = freqz(b_matched, a_matched, omega);
% Plotting magnitude responses
figure;
subplot(3,1,1);
plot(f, abs(H_bilinear), 'LineWidth', 2);
title('Magnitude Response: Bilinear Transformation');
xlabel('Frequency (Hz)');
ylabel('|H(f)|');
grid on;
xlim([0 Fs/2]);
subplot(3,1,2);
plot(f, abs(H_impulse), 'LineWidth', 2);
title('Magnitude Response: Impulse Invariant Transformation');
xlabel('Frequency (Hz)');
ylabel('|H(f)|');
grid on;
xlim([0 Fs/2]);

subplot(3,1,3);
plot(f, abs(H_matched), 'LineWidth', 2);
title('Magnitude Response: Matched Z-Transformation');
xlabel('Frequency (Hz)');
ylabel('|H(f)|');
grid on;
xlim([0 Fs/2]);
sgtitle('Comparison of Digital Filter Design Methods');

22
OUTPUT WAVEFORMS:

CONCLUSION:
In this experiment, second order Infinite Impulse Response (IIR) filter using various
transformation methoed was verified using matlab.

SUBMITTED BY:
Twinkle Pradhan
2202060021

23
EXPERIMENT-06

AIM OF THE EXPERIMENT:


Design of Finite Impulse Response (FIR) low pass and high pass filter and plot the gain
response using MATLAB.

SOFTWARE USED:
MATLAB R2024b

THEORY:
The specifications of the desired filter will be given in terms of ideal frequency response Hd(w).
The impulse response hd(n) of the desired filter can be obtained by inverse fourier transform
of Hd(w), which consists of infinite samples. The filters designed by selecting finite number of
samples of impulse response are 1 called FIR filters. If the Impulse Response of a system is of
finite duration then system is called finite impulse response (FIR).

Main advantages of FIR filter over IIR filter-

(i) FIR filters are always stable.


(ii) FIR filters with exactly linear phase can be easily designed.
(iii) FIR filters can be realised in both recursive and non-recursive structure.
(iv) FIR filters are free of limit cycle oscillation when implemented on a finite word
length digital system.
(v) Excent design methods are available for various kinds of FIR filters

 ωp - normalized cut-off frequency in the passband;


 ωs - normalized cut-off frequency in the stopband;
 δ1 - maximum ripples in the passband;
 δ2 - minimum attenuation in the stopband [dB];
 ap - maximum ripples in the passband; and
 as - minimum attenuation in the stopband [dB].

1+𝛿
𝑎𝑝 =20log 10 (1−𝛿1 )
1

𝑎𝑠 = −20 log10 𝛿2

Frequency normalization can be expressed as follows:

24
2𝜋𝑓
𝜔= 𝑓𝑠

where:

 fs is a sampling frequency;
 f is a frequency to normalize; and
 ω is normalized frequency.

MATLAB CODE:
clc;
clear;
close all;
% Filter specifications
Fs = 1000; % Sampling frequency in Hz
Fc_low = 100; % Cutoff frequency for low-pass filter
Fc_high = 200; % Cutoff frequency for high-pass filter
N = 50; % Filter order (should be even for symmetry)
% Design Low-pass FIR filter using Hamming window
h_low = fir1(N, Fc_low / (Fs / 2), 'low', hamming(N + 1));
% Design High-pass FIR filter using Hamming window
h_high = fir1(N, Fc_high / (Fs / 2), 'high', hamming(N + 1));
% Frequency response of filters
[H_low, f_low] = freqz(h_low, 1, 1024, Fs);
[H_high, f_high] = freqz(h_high, 1, 1024, Fs);
% Plot magnitude and phase response of Low-pass filter
figure;
subplot(2,1,1);
plot(f_low, abs(H_low), 'b', 'LineWidth', 1.5);
xlabel('Frequency (Hz)'); ylabel('Magnitude'); grid on;
title('Low-pass FIR Filter - Magnitude Response');
subplot(2,1,2);
plot(f_low, angle(H_low), 'r', 'LineWidth', 1.5);
xlabel('Frequency (Hz)'); ylabel('Phase (radians)'); grid on;
title('Low-pass FIR Filter - Phase Response');
% Plot magnitude and phase response of High-pass filter
figure;
subplot(2,1,1);
plot(f_high, abs(H_high), 'b', 'LineWidth', 1.5);
xlabel('Frequency (Hz)'); ylabel('Magnitude'); grid on;
title('High-pass FIR Filter - Magnitude Response');
subplot(2,1,2);
plot(f_high, angle(H_high), 'r', 'LineWidth', 1.5);
xlabel('Frequency (Hz)'); ylabel('Phase (radians)'); grid on;
title('High-pass FIR Filter - Phase Response');

25
OUTPUT WAVEFORMS:

CONCLUSION:
In this experiment, Design of Finite Impulse Response (FIR) low pass and high pass filter and
plot the gain response using MATLAB was verified .

SUBMITTED BY:
Twinkle Pradhan
2202060021

26

You might also like