0% found this document useful (0 votes)
28 views

Dsp Lab File

The document is a lab file for a Digital Signal Processing course at Delhi Technological University, detailing various experiments conducted using MATLAB. It includes experiments on discrete and continuous signals, FIR and IIR filter design, and the application of DFT and IDFT on sinusoidal signals. Each experiment outlines the aim, theory, software used, code, and results, showcasing the practical applications of digital signal processing techniques.

Uploaded by

wailabdalla901
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)
28 views

Dsp Lab File

The document is a lab file for a Digital Signal Processing course at Delhi Technological University, detailing various experiments conducted using MATLAB. It includes experiments on discrete and continuous signals, FIR and IIR filter design, and the application of DFT and IDFT on sinusoidal signals. Each experiment outlines the aim, theory, software used, code, and results, showcasing the practical applications of digital signal processing techniques.

Uploaded by

wailabdalla901
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/ 19

DELHI TECHNOLOGICAL UNIVERSITY

DIGITAL SIGNAL PROCESSING (EC-304)


LAB FILE

AMGAD HASSAN Submitted to:

2K22/EC/031 CHHAVI DHIMAN


Index

S. Experiment Date Remarks


NO.
1. To plot basic discrete and continuous signals. 13/01/2025
2. To plot linear convolution of two discrete 13/01/2025
sequences.
3. To perform the circular convolution of two 20/01/2025
given sequences
4. Design of a FIR Low pass, High pass, 27/01/2025
Bandpass, Band stop filter using a rectangular
window method.
5. To compute discrete Fourier transform 27/01/2025
(DFT) of discrete signals and plot their
magnitude and phaseresponse.
6. Illustration of Circular Shift Property Using MATLAB 03/02/2025

7. DFT and IDFT of a Composite Sinusoidal Signal for 03/02/2025


Different Lengths
8. FIR Filter Design and Signal Filtering Using MATLAB 10/02/2025
9. Design of IIR Filters Using MATLAB 24/03/2025
10. Design of Ideal IIR and FIR Filters Using MATLAB 24/03/2025
11. Design of a Low Pass IIR Butterworth Filter Using 07/04/2025
MATLAB
12. Design of Low Pass IIR Chebyshev Filters (Type-I and 07/04/2025
Type-II) Using MATLAB
EXPERIMENT NO 06

Illustration of Circular Shift Property Using MATLAB

• AIM:

To implement and visualize the circular shift property for a discrete-time signal X(n)={1,2,3,4}X(n) =
\{1, 2, 3, 4\}X(n)={1,2,3,4} and verify the result Y(n)={3,4,1,2}Y(n) = \{3, 4, 1, 2\}Y(n)={3,4,1,2} using
MATLAB.

• SOFTWARE USED:

MATLAB

• THEORY:

In digital signal processing, shifting operations are essential tools for manipulating discrete-time signals.
One such operation is the circular shift, which rotates the elements of a finite-length signal sequence in a
cyclic manner, as if arranged on a circle.

For a discrete-time signal X(n)={x0,x1,x2,...,xN−1}X(n) = \{x_0, x_1, x_2, ..., x_{N-1}\}X(n)={x0,x1


,x2,...,xN−1}, a circular shift moves each element to a new position, wrapping around the end of the
sequence. It is different from a linear shift where shifted elements might be lost or replaced with zeros. In
circular shifts:

• A left circular shift by kkk positions results in:

Y(n)={xk,xk+1,...,xN−1,x0,x1,...,xk−1}Y(n) = \{x_k, x_{k+1}, ..., x_{N-1}, x_0, x_1, ..., x_{k-


1}\}Y(n)={xk,xk+1,...,xN−1,x0,x1,...,xk−1}

• A right circular shift by kkk positions results in:

Y(n)={xN−k,xN−k+1,...,xN−1,x0,x1,...,xN−k−1}Y(n) = \{x_{N-k}, x_{N-k+1}, ..., x_{N-1}, x_0, x_1,


..., x_{N-k-1}\}Y(n)={xN−k,xN−k+1,...,xN−1,x0,x1,...,xN−k−1}

This concept is especially useful in circular convolution, FFT algorithms, and periodic signal analysis. It
preserves the structure of the data while reordering it in a cyclic fashion.

In MATLAB, the circular shift is implemented using the circshift() function, which takes a vector and the
3
number of positions to shift. Positive values indicate a right shift, while negative values indicate a left
shift.

In this experiment:

• The signal is X(n)={1,2,3,4}X(n) = \{1, 2, 3, 4\}X(n)={1,2,3,4}

• A left circular shift by 2 positions results in Y(n)={3,4,1,2}Y(n) = \{3, 4, 1, 2\}Y(n)={3,4,1,2}

• The first two elements move to the end of the sequence

This helps in visualizing how circular shift maintains the original data but reorders it cyclically.

• CODE:

4
5
• RESULT:

The circular left shift of X(n)={1,2,3,4}X(n) = \{1, 2, 3, 4\}X(n)={1,2,3,4} by 2 positions gives:


Y(n)={3,4,1,2}Y(n) = \{3, 4, 1, 2\}Y(n)={3,4,1,2}
The plots clearly show the original and shifted sequences, confirming the correctness of the circular shift operation.

EXP NO 07

DFT and IDFT of a Composite Sinusoidal Signal for Different Lengths

AIM:

To analyze and reconstruct a discrete-time signal composed of two sinusoids with frequencies f1=10 Hzf_1
= 10\,Hzf1=10Hz and f2=12 Hzf_2 = 12\,Hzf2=12Hz, sampled at 50 Hz, using a 256-point Discrete Fourier
Transform (DFT) and its corresponding Inverse DFT (IDFT), for signal lengths n=10,15,30,100n = 10, 15,
30, 100n=10,15,30,100

SOFTWARE USED:

MATLAB

6
• THEORY:

A sinusoidal signal can be represented as:


x(n)=sin⁡(2πf1nT)+sin⁡(2πf2nT)x(n) = \sin(2\pi f_1 n T) + \sin(2\pi f_2 n T)x(n)=sin(2πf1nT)+sin(2πf2
nT)
where:
• f1f_1f1 and f2f_2f2 are the signal frequencies in Hz,
• T=1fsT = \frac{1}{f_s}T=fs1 is the sampling interval,
• fs=50 Hzf_s = 50\,Hzfs=50Hz is the sampling frequency,
• nnn is the time index (sample points).
In this experiment, the signal is a sum of two sinusoids of 10 Hz and 12 Hz, sampled at 50 Hz.
DFT (Discrete Fourier Transform):
Used to convert a discrete-time signal into its frequency domain representation. A 256-point DFT is applied
using the fft() function, which zero-pads the signal if its length is less than 256.
IDFT (Inverse DFT):
Reconstructs the original signal from its frequency domain representation using ifft(). To improve visual
similarity, the reconstructed signal is scaled by a factor of 6 to account for energy spread due to zero-
padding in DFT.
By applying DFT and IDFT for different lengths n=10,15,30,100n = 10, 15, 30, 100n=10,15,30,100, we can
observe how signal length impacts frequency resolution and reconstruction quality.

• CODE:

7
8
• RESULT:

For all signal lengths (n=10,15,30,100n = 10, 15, 30, 100n=10,15,30,100), the original signal composed of
10 Hz and 12 Hz components was successfully analyzed using a 256-point DFT. The signal was then
reconstructed using IDFT and scaled by a factor of 6. The reconstructed signals closely matched the
originals, validating the frequency content and accuracy of the reconstruction, especially as nnn increases.

EXP NO 08:

AIM: 9
To design various FIR filters using MATLAB's filter Designer tool, apply them to a mixed sinusoidal signal,
and observe the filtering effects on the output.

SOFTWARE USED:

MATLAB

THEORY:

FIR (Finite Impulse Response) Filters are widely used in digital signal processing because of their stability
and linear-phase characteristics. FIR filters are defined by a finite number of coefficients and do not rely on
feedback.
Types of FIR Filters:
1. Lowpass Filter – Passes low frequencies, attenuates high frequencies
2. Highpass Filter – Passes high frequencies, attenuates low frequencies
3. Bandpass Filter – Allows frequencies within a specific range
4. Bandstop Filter (Notch) – Rejects a specific range of frequencies
These filters are designed by specifying filter order and cutoff frequencies. The designed filter can then be
used to process signals using MATLAB's filter() function.
In this experiment:
• A mixed sinusoidal signal x(t)=sin⁡(2πf1t)+sin⁡(2πf2t)x(t) = \sin(2\pi f_1 t) + \sin(2\pi f_2
t)x(t)=sin(2πf1t)+sin(2πf2t) is used
• Filters are designed and applied to extract or suppress frequency components

10
RESULT:

By applying various FIR filters to the mixed signal, different components were either suppressed or
retained:
• Lowpass preserved the 50 Hz signal
• Highpass retained the 200 Hz component
• Bandpass isolated a frequency range
• Bandstop removed the 200 Hz component
The effectiveness of filtering was observed visually through signal plots, demonstrating frequency-
selective behavior of FIR filters.

EXP NO 09:

AIM:

To design and analyze different types of Infinite Impulse Response (IIR) filters in MATLAB using
the filterDesigner tool and apply them to a mixed sinusoidal signal

11
SOFTWARE USED:

MATLAB

THEORY:

IIR (Infinite Impulse Response) Filters are a type of digital filter that uses both past output and current input
values. Unlike FIR filters, IIR filters can achieve sharp frequency responses with a lower filter order, making
them computationally efficient. However, they can introduce phase distortion and must be designed
carefully to ensure stability.
Types of IIR Filters:
1. Lowpass Filter – Allows low-frequency components to pass
2. Highpass Filter – Allows high-frequency components to pass
3. Bandpass Filter – Allows a certain range of frequencies to pass
4. Bandstop Filter (Notch) – Attenuates a specific range of frequencies
IIR filters are typically designed using standard prototypes like Butterworth, Chebyshev Type I & II, and
Elliptic filters. Each has its own characteristics:
• Butterworth – Maximally flat frequency response
• Chebyshev – Sharper roll-off but introduces ripples
• Elliptic – Most efficient roll-off but ripples in both passband and stopband

CODE :

% Define time and signal


fs = 1000; % Sampling frequency
t = 0:1/fs:1; % Time vector
f1 = 100; f2 = 300; % Signal frequencies

% Mixed signal
x = sin(2*pi*f1*t) + sin(2*pi*f2*t);

% Apply the IIR filter (e.g., 'Hd' is the exported filter)


y = filter(Hd, x); % Filter the signal

% Plotting
figure;
subplot(2,1,1);
plot(t, x); title('Original Signal'); xlabel('Time (s)'); ylabel('Amplitude');

subplot(2,1,2);
plot(t, y); title('Filtered Signal (IIR)'); xlabel('Time (s)'); ylabel('Amplitude');

12
RESULT:

IIR filters of various types (Butterworth, Chebyshev, Elliptic) were successfully designed and applied to
mixed sinusoidal signals. Each filter type showed distinct frequency-selective behavior:
• Butterworth offered smooth response
• Chebyshev gave sharper cutoff with ripples
• Elliptic provided steep roll-off with ripples in both bands
Signal plots demonstrated how IIR filters suppress unwanted frequencies effectively while preserving
desired components.

13
EXP NO 10:

AIM:

To design and compare ideal IIR and FIR filters using MATLAB, observe their frequency responses, and
apply them to a mixed sinusoidal signal to evaluate performance.

SOFTWARE USED:

MATLAB

THEORY:
In digital signal processing, ideal filters are theoretical filters that perfectly pass desired frequencies and
completely eliminate all others. In practice, these can only be approximated using FIR or IIR filter designs.
FIR (Finite Impulse Response) Filters:
• Linear phase
• Always stable
• Require higher order for sharp transitions
• Easier to design for ideal performance over finite duration
IIR (Infinite Impulse Response) Filters:
• Non-linear phase
• Require fewer coefficients for sharp transitions
• Can approximate ideal response more efficiently
• May have stability concerns
Filter Types to Design:
• Lowpass – Allows low-frequency components
• Highpass – Allows high-frequency components
• Bandpass – Allows frequencies within a specific range
• Bandstop – Suppresses a specific range

CODE:

fs = 1000; % Sampling frequency


t = 0:1/fs:1; % Time vector
f1 = 100; f2 = 300; % Signal frequencies

% Original signal
x = sin(2*pi*f1*t) + sin(2*pi*f2*t);

% Apply FIR and IIR filters


14
y_fir = filter(Hd_fir, x);
y_iir = filter(Hd_iir, x);

% Plotting
figure;
subplot(3,1,1);
plot(t, x); title('Original Signal'); xlabel('Time (s)'); ylabel('Amplitude');

subplot(3,1,2);
plot(t, y_fir); title('Filtered Signal using FIR'); xlabel('Time (s)');

subplot(3,1,3);
plot(t, y_iir); title('Filtered Signal using IIR'); xlabel('Time (s)');

RESULT:

Both FIR and IIR filters were designed to approximate ideal filter behavior. Results show:
• FIR filters produce smooth transitions and linear phase but need higher order
• IIR filters achieve sharper cutoffs with fewer coefficients but may distort phase
Visual plots demonstrate how each filter type removes unwanted frequency components from the mixed
signal effectively.
15
EXP NO 11:

AIM:

To design a Low Pass IIR Butterworth filter using MATLAB and apply it to a mixed sinusoidal signal to
analyze its performance.

SOFTWARE USED:

MATLAB

THEORY:

Butterworth filters are a type of IIR (Infinite Impulse Response) filter characterized by a maximally flat
frequency response in the passband and a monotonic transition to the stopband. It is ideal for applications
where signal smoothness and minimal distortion in the passband are critical.
Key Characteristics:
• Smooth, ripple-free passband
• Gentle roll-off compared to Chebyshev or Elliptic filters
• Non-linear phase response
Low Pass Filter:
• Allows low-frequency components to pass through
• Attenuates frequencies higher than the specified cutoff
Design Parameters:
• Filter Order (N): Determines the sharpness of the cutoff
• Cutoff Frequency (Fc): Frequency at which the filter transitions from passband to stopband
• Sampling Frequency (Fs): Should be at least twice the maximum signal frequency (Nyquist criterion)

CODE:

fs = 1000; % Sampling frequency


t = 0:1/fs:1; % Time vector
f1 = 100; f2 = 300; % Mixed signal frequencies

% Generate mixed signal


x = sin(2*pi*f1*t) + sin(2*pi*f2*t);

% Apply Butterworth Lowpass filter


y = filter(Hd_butter, x);

% Plotting
16
figure;
subplot(2,1,1);
plot(t, x); title('Original Signal'); xlabel('Time (s)'); ylabel('Amplitude');

subplot(2,1,2);
plot(t, y); title('Filtered Signal (Butterworth Lowpass)'); xlabel('Time (s)'); ylabel('Amplitude');

RESULT:

The Butterworth lowpass filter successfully suppressed the higher frequency (300 Hz) component from the
mixed signal while allowing the 100 Hz component to pass. The output signal retained a smooth waveform
with minimal ripple and effective attenuation, demonstrating the classic Butterworth filter characteristics.

17
EXP NO 12:

AIM:

To design Low Pass IIR Chebyshev filters of Type-I and Type-II using MATLAB and apply them to a
mixed sinusoidal signal to analyze and compare their performance.

SOFTWARE USED:

MATLAB

THEORY:

Chebyshev Filters are a family of IIR filters known for their sharper roll-off than Butterworth filters. They
are used when a sharper transition from passband to stopband is required.

Chebyshev Type-I Filter:


• Has ripple in the passband
• Monotonic stopband
• More efficient roll-off than Butterworth
• Defined by passband ripple and cutoff frequency
Chebyshev Type-II Filter:
• Has ripple in the stopband
• Flat passband (like Butterworth)
• Sharper roll-off compared to Butterworth, and sometimes sharper than Type-I

Low Pass Filter Characteristics:


• Passes low frequencies below the cutoff
• Attenuates high frequencies above the cutoff
• Designed using parameters: Filter Order, Cutoff Frequency, and Ripple Factor

CODE:

fs = 1000; % Sampling frequency


t = 0:1/fs:1; % Time vector
f1 = 100; f2 = 300; % Mixed signal frequencies

18
x = sin(2*pi*f1*t) + sin(2*pi*f2*t); % Mixed signal

% Apply filters
y_cheby1 = filter(Hd_cheby1, x);
y_cheby2 = filter(Hd_cheby2, x);

% Plotting
figure;

subplot(3,1,1);
plot(t, x); title('Original Signal'); xlabel('Time (s)'); ylabel('Amplitude');

subplot(3,1,2);
plot(t, y_cheby1); title('Chebyshev Type-I Filtered Signal'); xlabel('Time (s)');

subplot(3,1,3);
plot(t, y_cheby2); title('Chebyshev Type-II Filtered Signal'); xlabel('Time (s)');

RESULT:

• Chebyshev Type-I filtered signal retained sharper cutoff with slight ripples in the passband.
• Chebyshev Type-II gave a smooth passband but had controlled ripples in the stopband.
• Both effectively removed the higher-frequency component (300 Hz), but Chebyshev filters showed a
steeper roll-off than Butterworth.
19

You might also like