In: Electrical Engineering
a) Let ?(?) = cos(2??) and ?(?) = cos(20??). Write the mathematical expression for the Fourier transform of ?(?) = 4[1 + 0.5?(?)]?(?) as a function of both ? (rad/s) and ? (Hz) by hand. Moreover, plot the magnitude spectrum of ?(?) by hand as functions of both ? (rad/s) and ? (Hz).
b) By using a 2x1 subplot, plot ?(?) signal in the first row. Take ? between -20 s and 20 s with an increment of 1 ms. Limit the x-axis between -2 s and 2 s. Moreover, calculate and plot the magnitude spectrum of ?(?) as a function of ? (Hz) in the second row of the subplot. Note that, Fourier Transform of ?(?) should be calculated and plotted by using fft and fftshift functions of MATLAB. Limit the x-axis between -15 Hz and 15 Hz. Do not forget axis labels.
MATLAB code is given below in bold letters.
clc;
close all;
clear all;
% define sampling rate
fs = 1000; % sampling frequency
Ts = 1/fs; % sampling time
t = -2:Ts:2; % time vector
% define the signals m(t) and c(t)
m = cos(2*pi*t);
c = cos(20*pi*t);
% define s(t)
s = 4*(1+0.5*m).*c;
% Finding FFT of s(t)
N = nextpow2(length(s));
S = fftshift(fft(s,2^N));
S = S / length(s);
k = -(length(S)-1)/2:1:length(S)/2;
f = k/length(S) * fs;
% plot the signals and its spectrum
figure;
subplot(211);
plot(t,s);grid;
xlabel('time');
ylabel('Amplitude');
title('s(t)');
subplot(212);
plot(f,abs(S));grid;
xlabel('Frequency in Hz');
ylabel('Amplitude');xlim([-15 15]);
title('Double sided Magnitude spectrum of s(t)');