Project3
Project3
Objective
The primary objective of this project is to design a 6th-order Chebyshev Type I high-pass
filter and analyze its performance based on given specifications. The project also involves
comparing the designed filter with Chebyshev filters of di?erent orders and an equivalent
Butterworth high-pass filter. Finally, the behavior of the designed filter is studied under
di?erent input signals to evaluate its practical performance.
Introduction
High-pass filters are widely used in signal processing to block low-frequency components
while allowing high-frequency components to pass through. The Chebyshev Type I filter is
known for its sharp transition between the passband and stopband, achieved at the cost of
ripples in the passband. Conversely, the Butterworth filter provides a smooth and ripple-
free response but with a less steep transition.
2. Verifying the -3 dB cuto? frequency and its alignment with the filter specifications.
3. Studying the impact of filter order by comparing Chebyshev filters of orders 4, 6, and
8.
5. Evaluating the response of the designed Chebyshev filter under di?erent input
signals.
Theory
o The sharpness of the roll-o? and the amount of ripple are determined by the
filter design specifications, including passband ripple and stopband
attenuation.
2. Butterworth Filters:
3. Key Parameters:
4. MATLAB Tools:
o The cheby1 and butter functions were used to design the filters.
o The freqz function was used to compute the frequency and phase responses.
MATLAB Code
The following MATLAB code was used to design and analyze the filters:
1. Chebyshev Type I Filter Design: A 6th-order Chebyshev Type I high-pass filter was
designed using cheby1. The magnitude and phase responses were plotted.
% Specifications
N = 6; % Filter order
Rp = 1; % Passband ripple in dB
Wp = 0.7 * pi; % Passband frequency
[b_cheby6, a_cheby6] = cheby1(N, Rp, Wp/pi, 'high');
[H_cheby6, w] = freqz(b_cheby6, a_cheby6, 16384);
% Plotting
subplot(2, 1, 1);
plot(w / pi, 20 * log10(abs(H_cheby6)), 'b');
title('Magnitude Response');
xlabel('Normalized Frequency (\omega / \pi)');
ylabel('Magnitude (dB)');
grid on;
subplot(2, 1, 2);
plot(w / pi, angle(H_cheby6), 'b');
title('Phase Response');
xlabel('Normalized Frequency (\omega / \pi)');
ylabel('Phase (radians)');
grid on;
Identification of the -3 dB CutoR: A zoomed-in magnitude response was plotted, and the
cuto? frequency was identified by interpolation.
Comparison of Filters with DiRerent Orders: Filters of orders 4, 6, and 8 were designed,
and their magnitude responses were compared.
Output for Given Inputs: The filter's output response to sinusoidal and step inputs was
analyzed.
% Test inputs
x1 = sin(pi/8 * n);
y1 = filter(b_cheby6, a_cheby6, x1);
• The magnitude response exhibits a sharp roll-o? from the stopband to the
passband, with ripples in the passband as specified (-1 dB). The stopband
attenuation exceeds the requirement of -40 dB.
• The phase response is non-linear, especially near the cuto? frequency, which is
typical for Chebyshev filters.
Figure: 01
• This closely aligns with the specified passband frequency of 0.7π ≈ 2.1990.7,
confirming the filter's design accuracy.
Figure: 02
3. Comparison of Chebyshev Filters with Orders 4, 6, and 8
• Order 4:
• Order 6:
• Order 8:
• The Butterworth filter was designed with the same cuto? frequency as the 6th-order
Chebyshev filter.
• Magnitude Response:
o The Butterworth filter has a smooth passband with no ripples, unlike the
Chebyshev filter.
o The roll-o? of the Butterworth filter is more gradual, making it less selective
than the Chebyshev filter.
Figure: 04
• Phase Response:
• Summary of DiRerences:
The 6th-order Chebyshev filter was tested with three input signals:
• Input 1 (x1[n]=sin(π/8⋅n):
o This frequency lies in the passband, resulting in minimal attenuation.
• Input 2 (x2[n]=sin(3π/4⋅n):
• Input 3 (x3[n]=u[n]:
Figure: 06
Conclusion
The project successfully demonstrated the design and analysis of Chebyshev Type I and
Butterworth high-pass filters. Key findings include:
1. The 6th-order Chebyshev filter met the design specifications with a -3 dB cuto?
frequency of 2.1803 rad/sample.
2. Increasing the filter order enhances the sharpness of the cuto? but introduces
phase nonlinearity and increases computational complexity.
3. The Butterworth filter o?ers a smooth response with no passband ripple but a less
steep roll-o? compared to the Chebyshev filter.
This project highlights the trade-o?s in high-pass filter design and provides valuable
insights into the practical applications of Chebyshev and Butterworth filters in signal
processing.
APPENDIX
MATLAB CODE
% Filter Specifications
Fs = 1; % Sampling frequency (1 Hz for 1-second sampling period)
Wp = 0.7 * pi; % Passband frequency in radians/sample
Ws = 0.3 * pi; % Stopband frequency in radians/sample
Rp = 1; % Passband ripple in dB
Rs = 40; % Stopband attenuation in dB
N = 6; % Filter order for Chebyshev Type I (Part I)
subplot(2, 1, 2);
plot(w / pi, angle(H_cheby6), 'b', 'LineWidth', 1.2);
title('Phase Response (6th Order Chebyshev Type I High-Pass Filter)');
xlabel('Normalized Frequency (\omega / \pi)');
ylabel('Phase (radians)');
grid on;
% Find the two points surrounding the user's click for interpolation
[~, idx] = min(abs(w / pi - cross_freq)); % Closest index to user's click
figure;
subplot(3, 1, 1);
plot(n, y1_cheby6);
title('Output Response to x_1[n] = sin(\pi/8 \cdot n) (Chebyshev Type I)');
xlabel('n');
ylabel('y_1[n]');
grid on;
subplot(3, 1, 2);
plot(n, y2_cheby6);
title('Output Response to x_2[n] = sin(3\pi/4 \cdot n) (Chebyshev Type I)');
xlabel('n');
ylabel('y_2[n]');
grid on;
subplot(3, 1, 3);
plot(n, y3_cheby6);
title('Output Response to x_3[n] = u[n] (Chebyshev Type I)');
xlabel('n');
ylabel('y_3[n]');
grid on;
Introduction
Digital filters are vital tools in signal processing applications, such as noise removal,
frequency selection, and signal enhancement. This report focuses on the design of an FIR
bandpass filter using the Kaiser window method and compares its performance against
other windowing techniques, namely Hamming, Hanning, and Blackman windows. The
design adheres to the following specifications:
The report addresses the filter design process, evaluates the frequency and time-domain
characteristics, and explores the trade-o?s between di?erent windowing techniques to
answer all parts of the problem.
Background
FIR (Finite Impulse Response) filters are inherently stable and exhibit a linear phase
response, making them ideal for applications requiring precise frequency-domain
performance. Designing an FIR filter involves approximating an ideal frequency response
(e.g., a bandpass filter) with a finite-length impulse response.
o The ideal bandpass filter has a frequency response with unity gain in the
passband and zero gain in the stopband. However, its impulse response is
infinite in length and non-implementable.
Windowing Techniques
1. Kaiser Window:
o The Kaiser window allows a tunable trade-o? between main lobe width and
side lobe attenuation via the beta parameter.
o The kaiserord function in MATLAB determines the required filter order and
beta value based on stopband attenuation and transition width.
3. Blackman Window:
o A window with the lowest side lobe levels, achieving excellent stopband
attenuation but with a wider main lobe, resulting in less sharp transitions.
MATLAB Code
The MATLAB code provided implements the FIR bandpass filter design using the Kaiser
window and compares it to filters designed with the Hamming, Hanning, and Blackman
windows.
Kaiser Window Filter Design: The kaiserord function estimates the required filter order and
the Kaiser beta parameter. The fir1 function designs the FIR filter.
% Specifications
fs = 1000; % Sampling frequency
passband_freq = [pi/4 pi/2]; % Passband frequencies in radians/sample
stopband_atten = 50; % Stopband attenuation in dB
% Normalize frequencies
passband_freq_hz = passband_freq * fs / (2 * pi); % Convert to Hz
f_p = passband_freq_hz / (fs / 2); % Normalize to 0-1 scale
Filter Design Using Other Windows: Filters were redesigned using the Hamming,
Hanning, and Blackman windows with the same filter order.
Results
The Kaiser window method was used to design the filter. The MATLAB function kaiserord
estimated the minimum filter order, ensuring the stopband attenuation of 50 dB. Below,
Figure 1 shows the magnitude response of the FIR bandpass filter designed using the
Kaiser window. The passband (125–250 Hz) is preserved, and the stopband attenuation
exceeds the required 50 dB.
The FIR bandpass filter was redesigned using Hamming, Hanning, and Blackman windows
with the same filter order (N=36N = 36N=36) for a fair comparison. Each filter’s magnitude
response is compared in Figure 2.
Part V: Plot the Magnitude Responses for Comparison
Figure 2 : Comparison of magnitude responses for FIR bandpass filters designed using
Kaiser, Hamming, Hanning, and Blackman windows. The trade-oRs in stopband
attenuation and transition width are evident.
• Passband Behavior: All filters maintain a flat passband within 125–250 Hz.
• Stopband Behavior: Blackman achieves the best stopband attenuation, followed
by Kaiser. Hamming and Hanning have higher side lobes, reducing their attenuation.
• Transition Width: Blackman has the widest transition band, while Hamming and
Hanning o?er sharper transitions.
• The Kaiser window provides a balanced impulse response with minimal oscillations.
• The Blackman window results in a longer decay due to its wider main lobe.
• The Hamming and Hanning windows show more pronounced oscillations due to
higher side lobe levels.
Figure 3: Impulse responses of FIR bandpass filters designed with diRerent window
functions. The Kaiser window shows minimal oscillations, while the Blackman
window exhibits smoother decay.
Discussion
• Passband: All filters achieve a flat passband within the specified range of 125 Hz to
250 Hz.
• Stopband: Blackman provides the best attenuation, followed by Kaiser, Hamming,
and Hanning.
• Transition Width:Blackman has the widest transition band, while Hamming and
Hanning o?er sharper transitions.
VIII. Relationship Between Window Function, Main Lobe Width, and Side Lobe
Levels:
• Main Lobe Width: A wider main lobe (e.g., Blackman) results in smoother
transitions but compromises sharpness. A narrower main lobe (e.g., Kaiser,
Hamming) ensures sharp transitions but may lead to higher side lobes.
• Side Lobe Levels: Lower side lobe levels reduce stopband ripple. Blackman excels
in this regard, followed by Kaiser.
• Impulse Response: Higher side lobes correlate with more oscillations in the
impulse response.
Conclusion
Filter Order: The Kaiser window method accurately determines the filter order required for
the specified stopband attenuation.
Frequency Response: Blackman provides the best stopband attenuation, while Hamming
and Hanning excel in sharp transitions. Kaiser balances these characteristics, making it
versatile.
Impulse Response: Kaiser o?ers a balanced response, while Blackman decays more
smoothly.
Recommendations:
• Use Kaiser for flexible designs.
• Use Blackman for applications requiring minimal leakage.
• Use Hamming/Hanning for sharp transitions.
This study highlights the trade-o?s in FIR filter design and demonstrates the impact of
window choice on frequency and time-domain performance.
APPENDIX
MATLAB CODE
% Specifications
fs = 1000; % Sampling frequency (Hz)
passband_freq = [pi/4 pi/2]; % Passband frequencies (radians/sample)
stopband_atten = 50; % Stopband attenuation (dB)
subplot(4, 1, 2);
stem(b_hamming);
title('Impulse Response - Hamming Window');
xlabel('n'); ylabel('Amplitude');
subplot(4, 1, 3);
stem(b_hanning);
title('Impulse Response - Hanning Window');
xlabel('n'); ylabel('Amplitude');
subplot(4, 1, 4);
stem(b_blackman);
title('Impulse Response - Blackman Window');
xlabel('n'); ylabel('Amplitude');
grid on;
% Discuss the main lobe width and side lobe levels in the report to be provided later.