Signal Processing Assignment2
Signal Processing Assignment2
Table of Contents
General Information ............................................................................................................................. 1
Clean Up ........................................................................................................................................... 1
Parameter Definitions (Signal Generation With and Without Noise) ............................................................. 1
Parameter Definitions (For FFT Calculation) ........................................................................................... 2
Plotting the Signals with their Frequency Spectrums ................................................................................. 2
General Information
Author: Haider Hasan Hamood
Objective: We want to generate a sinusoidal signal with 3 frequencies (5, 10, 15 Hz) and find its Single-Sided and
Double-Sided Amplitude Spectrum Using FFT with and without noise
Clean Up
clear;
clc;
close all;
1
Assignment 2: Signal Pro-
cessing Using MATLAB
P2_1 = abs(SIG_FFT_No_Noise_singleSided/signal_length);
P1_1 = P2_1(1:signal_length/2 + 1);
P1_1(2:end) = P1_1(2:end)*2;
% Single-Sided Spectrum...
f_singleSided = (0:signal_length/2) * 2*Fs/signal_length;
% Double-Sided Spectrum...
f_doubleSided = (-signal_length/2:signal_length/2 - 1) * (2*Fs/signal_length);
SIG_FFT_No_Noise_doubleSided = fftshift(SIG_FFT_No_Noise_singleSided);
% We'll use the same signal length and frequency range for the noisy signal
P2_2 = abs(SIG_FFT_with_Noise_singleSided/signal_length);
P1_2 = P2_2(1:signal_length/2 + 1);
P1_2(2:end) = P1_2(2:end)*2;
SIG_FFT_with_Noise_doubleSided = fftshift(SIG_FFT_with_Noise_singleSided);
2
Assignment 2: Signal Pro-
cessing Using MATLAB
subplot(3, 1, 2);
plot(f_singleSided, P1_1); xlabel('f (Hz)'); ylabel('|P1(f)|');
title('Single-Sided Amplitude Spectrum of the signal (no noise)');
grid on;
subplot(3, 1, 3);
plot(f_doubleSided, abs(SIG_FFT_No_Noise_doubleSided/signal_length));
xlabel('f (Hz)'); ylabel('|P1(f)|');
title('Double-Sided Spectrum of the signal (no noise)');
grid on;
figure(2);
subplot(3, 1, 1);
plot(t, signal_with_noise); xlabel('Time (s)'); ylabel('Power (mW)');
title('Time domain of the signal (with noise)');
grid on;
subplot(3, 1, 2);
plot(f_singleSided, P1_2); xlabel('f (Hz)'); ylabel('|P1(f)|');
title('Single-Sided Amplitude Spectrum of the signal (with noise)');
grid on;
subplot(3, 1, 3);
plot(f_doubleSided, abs(SIG_FFT_with_Noise_doubleSided/signal_length));
xlabel('f (Hz)'); ylabel('|P1(f)|');
title('Double-Sided Spectrum of the signal (with noise)');
grid on;
3
Assignment 2: Signal Pro-
cessing Using MATLAB
4
University of Kufa 9th – Mar – 2024
Assignment 2: Signal
Processing Using Matlab
Haider Hasan Hamood // 3rd Stage -Morning Study-
ECE // University of Kufa
Simulink System
Results
5 Hz 10 Hz 15 Hz
5 Hz 10 Hz 15 Hz
Fig. 2: The signal (with and without noise) in the time domain
Fig. 3: The signal (without noise) in the frequency domain (dB scale)
Fig. 4: The signal (with noise) in the frequency domain (dB scale)
Fig. 5: The signal (with and without noise) in the frequency domain (dB scale)
Fig. 6: The signal (without noise) in the frequency domain (Linear scale)
Fig. 7: The signal (with noise) in the frequency domain (Linear scale)