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

Signal Processing Assignment3

The document describes generating a signal with 3 frequencies and applying LPF, HPF, and BPF filters to it in MATLAB. It defines parameters for the signal generation and filters. Plots of the signal and filtered results are shown. Filter cutoffs are defined as 40 Hz for the LPF, 120 Hz for the HPF, and 70-120 Hz for the BPF.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Signal Processing Assignment3

The document describes generating a signal with 3 frequencies and applying LPF, HPF, and BPF filters to it in MATLAB. It defines parameters for the signal generation and filters. Plots of the signal and filtered results are shown. Filter cutoffs are defined as 40 Hz for the LPF, 120 Hz for the HPF, and 70-120 Hz for the BPF.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Assignment 3: Signal

Processing Using MATLAB

Table of Contents
General Information ............................................................................................................................. 1
Clean Up ........................................................................................................................................... 1
Parameter Definitions (Signal Generation With and Without Noise) ............................................................. 1
Plotting the Signal With and Without Noise In Time Domain ..................................................................... 2
Parameter Definition (Filters Frequencies) ............................................................................................... 4
Applying Filtering and Plotting The Results ............................................................................................ 4

General Information
Author: Haider Hasan Hamood

Date Created: 11-3-2024

Context: ECE308, Computer Aided Communication Systems Design Lab

Objective: We want to generate a sinusoidal signal with 3 frequencies (50, 100, 150 Hz) and apply LPF, HPF, and
BPF to it with white noise added

Clean Up
clear;
clc;
close all;

Parameter Definitions (Signal Generation With


and Without Noise)
frequencies = [50 100 150]; % [Hz] the 3 frequencies for the signal
Fs = 500; % [Hz] The sampling frequency
Ts = 1/Fs; % [s] The sampling time

time_interval_1 = 0:Ts:2-Ts; % [s] Time interval 1, corresponds to f = 5 Hz


time_interval_2 = 2:Ts:4-Ts; % [s] Time interval 2, corresponds to f = 10 Hz
time_interval_3 = 4:Ts:6-Ts; % [s] Time interval 3, corresponds to f = 15 Hz
t = [time_interval_1 time_interval_2 time_interval_3]; % [s] time intervals
grouped in one vector

sig_no_noise1 = sin(2*pi*frequencies(1)*time_interval_1); % [mW] first part of


the signal (with f = 5 Hz)

1
Assignment 3: Signal Pro-
cessing Using MATLAB

sig_no_noise2 = sin(2*pi*frequencies(2)*time_interval_2); % [mW] second part


of the signal (with f = 10 Hz)
sig_no_noise3 = sin(2*pi*frequencies(3)*time_interval_3); % [mW] third part of
the signal (with f = 15 Hz)

signal_no_noise = [sig_no_noise1 sig_no_noise2 sig_no_noise3]; % [mW] the 3


parts of the signal grouped in one vector

noise = 0.2*randn(size(t)); % the noise to be added to the signal


signal1_with_noise = sig_no_noise1 + noise(1:1/3*size(t, 2)); % [mW] the
signal with noise added
signal2_with_noise = sig_no_noise2 + noise(1/3*size(t, 2)+1:2/3*size(t, 2)); %
[mW] the signal with noise added
signal3_with_noise = sig_no_noise3 + noise(2/3*size(t, 2)+1:size(t, 2)); %
[mW] the signal with noise added

signal_with_noise = [signal1_with_noise signal2_with_noise


signal3_with_noise];

Plotting the Signal With and Without Noise In


Time Domain
figure(1);

plot(time_interval_1, sig_no_noise1, 'b');


hold on;
plot(time_interval_2, sig_no_noise2, 'r');
plot(time_interval_3, sig_no_noise3, 'y');
xlabel('time (s)'); ylabel('Power (mW)');
title('Signal (No Noise)');
legend('f1=50 Hz', 'f2=100 Hz', 'f3= 150 Hz');
hold off;

figure(2);
plot(time_interval_1, signal1_with_noise, 'b');
hold on;
plot(time_interval_2, signal2_with_noise, 'r');
plot(time_interval_3, signal3_with_noise, 'y');
title('Signal (With Noise)');
xlabel('time (s)'); ylabel('Power (mW)');
legend('f1=50 Hz', 'f2=100 Hz', 'f3= 150 Hz');
hold off;

2
Assignment 3: Signal Pro-
cessing Using MATLAB

3
Assignment 3: Signal Pro-
cessing Using MATLAB

Parameter Definition (Filters Frequencies)


LPF_fPass = 40; % [Hz] low pass filter cutoff frequency

HPF_fPass = 120; % [Hz] high pass filter cutoff frequency

BPF_fPass = [70 120]; % [Hz] bandpass filter frequency range

Applying Filtering and Plotting The Results


figure(3);
lowpass(signal_with_noise, LPF_fPass, Fs)

figure(4);
highpass(signal_with_noise, HPF_fPass, Fs)

figure(5);
bandpass(signal_with_noise, BPF_fPass, Fs)

4
Assignment 3: Signal Pro-
cessing Using MATLAB

5
Assignment 3: Signal Pro-
cessing Using MATLAB

Published with MATLAB® R2023a

6
University of Kufa 14th – Mar – 2024

Assignment 3: Signal
Processing Using Matlab
Haider Hasan Hamood // 3rd Stage -Morning Study-
ECE // University of Kufa

Simulink System

Fig. 1: Simulink System

Page | 1 Computer Aided Comm. Systems Design


University of Kufa 14th – Mar – 2024

Filters Parameters

(a)

(b)

(c)

Fig. 2: Parameters of (a) LPF, (b) HPF, (c) BPF

Page | 2 Computer Aided Comm. Systems Design


University of Kufa 14th – Mar – 2024

Results

Before Filtering

After Filtering

(a)

Before Filtering

After Filtering

(b)

Page | 3 Computer Aided Comm. Systems Design


University of Kufa 14th – Mar – 2024

Before Filtering

After Filtering

(c)

Fig. 3: Spectrum with (a) LPF, (b) BPF, (c) HPF

Page | 4 Computer Aided Comm. Systems Design

You might also like