ECE251s Signals Project
ECE251s Signals Project
PREPARED BY:
• Omar Samir Salem Mohamed: 2300720.
• Yousef Osama Elsayed Mohamed: 2300647.
• Ziad Mohamed Sobhy Ali: 2300089.
• Mostafa Ramadan Mohamed: 2300486.
• Ali Amir Abouzaid Abdelhamid: 2300157.
• Youssef Ahmed Hassan Fakhry 2300551.
• Mohamed Hisham Saad Elsayed 2301257.
• Youssef Mohamed Ahmed Eladawy 2300578.
• Youssef Mohamed Ali Abubakr 2300652.
• Zeyad Saber Hussein Mohamed 2300247.
PREPARED FOR:
Dr. George Albert Adib Abdel Sayed
Names Contribution
Ziad Mohamed Sobhy Ali Preparing audio file (.wav) and
Mostafa Ramdan Mohamed calculating time-domain energy
Ali Amir Abouzaid Abdelhamid Performing Fast-Fourier-Tranform
Youssef Mohamed Ali Abubakr ,calculating Frequency-domain
energy
Yousef Osama Elsayed Mohamed Designing and applying the 10th-
Zeyad Saber Hussein Mohamed order Butterworth filter (low-pass)
Omar Samir Salem Mohamed Saving the output audio and writing
Mohamed Hisham Saad Elsayed the projects documentation
CONTENTS:
1.Project Overview
2.Code Review
3.Waveforms (plots)
4.Full Code (copyable)
1.PROJECT OVERVIEW
This project uses MATLAB to apply a 10th-order Butterworth low-pass
filter to an audio file in the frequency domain. We then convert the filtered
signal back to the time domain, plot every waveform (original and
filtered), and save the result as a new audio file.
Code Procedure:
1. Read & plot the raw audio
8. IFFT-shift and IFFT to get the signal back into the time domain
9. Plot time domain and frequency domain signal before and after
filtering
-audioread(): Reads the wav audio and puts it into a a vector called
timeSignal of size (N*1) and stores the sampling rate for future
calculations
-We also store the length of the signal vector (total number of samples N)
-We create a timeAxis vector so we can plot the time on the x axis
2. Time-Domain Energy:
energyTimeDomain = sum(abs(timeSignal).^2);
Computes the total signal energy in time domain through the relation:
𝑁−1
𝐸𝑡 = ∑ |𝑥[𝑛]|2
𝑛=0
3. Frequency-Domain Analysis:
freqSignal = fft(timeSignal);
freqSignalShifted = fftshift(freqSignal);
freqAxis = (-floor(signalLength/2):ceil(signalLength/2)-1) * (sampleRate /
signalLength);
energyFreqDomain = (1/signalLength) * sum(abs(freqSignal).^2);
Parseval’s theorem guarantees that the total energy calculated in the time
domain is exactly the same as the total energy calculated in the frequency
domain
𝑁−1 𝑁−1
1
∑ |𝑥[𝑛]|2 = ∑ |𝑋[𝑘]|2
𝑁
𝑛=0 𝑘=0
-Calculate the filter’s frequency response for each freq bin through the
equation:
1
𝐻(𝑓) =
|𝑓| 2𝑁
√1 + ( )
𝑓𝑐
-We apply the filter in the frequency domain by multiplying each bin by its
frequency response or gain in the H vector
-ifftshift: Re‐orders the bins back into the FFT’s natural ordering (0 to Fs)
so we can use ifft
%% 2. Time-Domain Energy
energyTimeDomain = sum(abs(timeSignal).^2);
%% 3. Frequency-Domain Analysis
freqSignal = fft(timeSignal);
freqSignalShifted = fftshift(freqSignal);
freqAxis = (-floor(signalLength/2):ceil(signalLength/2)-1) * (sampleRate /
signalLength);
energyFreqDomain = (1/signalLength) * sum(abs(freqSignal).^2);
halfIdx = 1 : floor(signalLength/2)+1;
f_pos_khz = (halfIdx-1) * (sampleRate/signalLength) / 1000;
origMag_pos = abs(freqSignal(halfIdx)) / signalLength;
filtMag_pos = abs(filteredFreqSignal(halfIdx)) / signalLength;
sgtitle(titleStr,'FontSize',12,'FontWeight','bold');
%% 8. Save Filtered Audio
audiowrite(outputFilename, filteredTimeSignal, sampleRate);
disp(['Filtered audio saved to ', outputFilename]);