MATLAB Assignment # 1: EGRE 336: Introduction to Communication Systems
Department of Electrical and Computer Engineering
Virginia Commonwealth University
October 18, 2021 —- Fall 2021
Part 1: Plotting in Time and Frequency Domains
Consider the Fourier transform pai
x(t) = Π(2t) ⇐⇒ 1
2
sinc(
f
2
) = X(f)
1. Plot the magnitude of X(f) for −5 ≤ f ≤ 5
2. Plot the phase in degrees for X(f) for −5 ≤ f ≤ 5
3. Plot y(t) = Π(2t) cos(2π10t) −0.5 ≤ t ≤ 0.5
4. Plot the magnitude of the Fourier transform | Y (f) | of y(t) = Π(2t)5ej2π5t for 0 ≤ f ≤ 10
5. Plot the phase in degrees for z(t) = x(t− 0.2)
Use a step size of .001 for all plots.
All 5 plots should display in a single window, using subplots, titles, x and y labels. The title for you
the last subplot should also have your name and date on it.
MATLAB commands that may be useful are abs(), angle(), rad2deg(), wrapTo180(). If you are
writing your own code for the sinc function, be careful how you handle t = 0. If you are using the
MATLAB function sinc(), make sure it has the same definition of the sinc function as the text book.
Part 2: Using the conv command to find the response of a system
1. A system is described by the impulse response h(t) = t, 0 ≤ t ≤ 10. Compute and plot the response
of the system to the input signal x(t) = 0.8t, 0 ≤ t ≤ 10.
2. A system is described by the impulse response h(t) = e−2tu(t− 1). Compute and plot the response
of the system to the input signal x(t) = u(t)− u(t− 2).
Part 3: Using the fft command to find the Fourier Transform of a signal
Review the Discrete Fourier Transform from EGRE 335. Recall that the DFT is periodic in 2π.
Study the code in the file fou ex.m.
You can use the code in the example file to find the magnitude and phase of a fft signal. Make sure you
understand the command fftshift() and also how you shift the signal so that the center is at zero. You
should also be able to manipulate the vectors to plot a single sided Fourier transform (xlim command).
Given a message signal
m(t) = XXXXXXXXXXsin(2π55t XXXXXXXXXXcos(2π110t) for 0 ≤ t ≤ 10
Using the MATLAB fft() function plot the following
1. Plot m(t) for 3 periods, starting at t = 0 (Convince yourself the signal is periodic and find the
period).
2. Plot the unshifted magnitude plot of M(f)
3. Plot the zero centered plot of magnitude plot of M(f) (you need to use the ffshift() function)
4. Truncate the above plot in (3) for the range −130 ≤ f ≤ 130
5. Plot the single sided magnitude plot of M(f) for the range 0 ≤ f ≤ 120
Use a step size of .001 for all plots.
All 5 plots should display in a single window, using subplot, title, xlabel and ylabel. The title fo
your the last subplot should also have your name and date on it.
Deliverables
Turn in on Canvas:
1. Single m file, with a pause statement after each pop up plot window. On completion of the run, all
three windows should still be displayed.
2. PDF of the plots for each pop-up window. (total of 3 pages)
3. Name your file FirstName.m (example: JohnDoe.m)
Due Date
The assignment should be submitted on Canvas no later than 11:59 pm on Monday, November 1, 2021.
clear all
close all
fs = 100; % sampling frequency
t = 0:(1/fs):(10-1/fs); % time vecto
%% message signal m(t)
mt = cos(2*pi*15*t);
%%length of message signal
n = length(mt);
f = (0:n-1)*(fs/n); %frequency range
%% M(f) the fft of message signal (amplitude divided by number of points)
Mf = fft(mt)/n;
%% Magniitude of M(f)
Mf_abs = abs((Mf));
figure(1)
subplot(3,1,1)
plot(f,Mf_abs,'color','blue','LineWidth',1.5)
xlabel('frequency Hz')
ylabel('Magnitude M(f)')
title ('M(f) before flipping')
% Note that fft is peridic in 2pi and it is plotting from 0 to 2 pi.
% fftshift flips the fourier transform.
Mf_shift = fftshift(Mf);
subplot(3,1,2)
plot(f,abs(Mf_shift),'color','blue','LineWidth',1.5)
xlabel('frequency Hz')
ylabel('Magnitude M(f)')
title ('Shifted FFT of m(t)')
%% shifting the frequency axis to center around origin
fshift = (-n/2:n/2-1)*(fs/n);
subplot(3,1,3)
plot(fshift,abs(Mf_shift),'color','blue','LineWidth',1.5)
xlabel('frequency Hz')
ylabel('Magnitude M(f)')
title ('Zero Centered Shifted FFT of m(t), Ashok Iyer 10/18/2021')