Dsp Lab File
Dsp Lab File
• 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.
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:
This helps in visualizing how circular shift maintains the original data but reorders it cyclically.
• CODE:
4
5
• RESULT:
EXP NO 07
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:
• 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 :
% Mixed signal
x = sin(2*pi*f1*t) + sin(2*pi*f2*t);
% 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:
% Original signal
x = sin(2*pi*f1*t) + sin(2*pi*f2*t);
% 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:
% 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.
CODE:
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