I need to finish the Part a c f. And I need to use matlab coding to finsh it. I
ID: 2294193 • Letter: I
Question
I need to finish the Part a c f. And I need to use matlab coding to finsh it. I need the codes. Thank you.
Find the Fourier transform X(jw) of each of the following signals, and sketch the corresponding magnitude spectrum X(jo)l (a) x(t) = e"u(-1), a > 0. (c) x(t)-6(t-to) + ?(t + to), (d) x(1) = ?(t-to)-6(1 + to). (e) x(1)-e-"Icosooju(1), coo» a >0. [Hint: Here X(jo)|- (b) x(r)-e a0. X,(jo)l + X2(jw)I with x(t)-n(1) + x2(t).] (f) x(t)-[cos ?11(1 + 1)-a(1-1)]. (g) x() = [sin ?[u(t + 1)-n(1-1)]. (h) x(1)-[1 + cos ???(1 + 1)-11(1-1)]. x(t) 0) x(n) TO T -TExplanation / Answer
The u.m file is as follows for the heviside unit step function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%The heviside unit step function
function y = u(n)
y = 0 *n;
y(find(n>=0)) = 1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
The d.m file will be as follows for delta dirac function
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% delta dirac function
function y = d(n)
y = 0*n;
y(find(n==0)) = 1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
As we know that the Discrete Fourier transform calculate the value of Discrete Time Fourier transform, but also discrete in frequency. Hence when we take the frequency steps too close we can actually realize the DTFT by using DFT.
The best way to calculate DFT is by using the FFT algorithm. Hence we will use FFT algorithm to calculate the DFT at very close frequency values and plot the digital plot as a analog plot.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Plot of Frequency
clear all;
close all;
T = 0.01; % The sampling frequency
t = -10:T:10-T; % take time from -10 sec to 10 sec
w = 0:0.001:2*pi;
N = size(w,2);
% for part a of the question
a = 0.1;
x_a_t = exp(a*t).*u(t);
figure ("Name","PLot of function in time")
plot(t,x_a_t);
%calulate FFT of the function with same number of samples as in w
Xw = (1/N) * fft(x_a_t,N); % rescalling the FFT with factor 1/N will give actuall rms values at the corresponding freq
% calulate magnitude of FFT
MXw = abs(Xw);
figure("Name", "Plot of function in frequency")
plot(w,MXw);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% for part c of the question
a = 0.1;
w0 = 100;
x_c_t = exp(a*t).*cos(w0*t).*u(t);
figure ("Name","PLot of function in time")
plot(t,x_c_t);
%calulate FFT of the function with same number of samples as in w
Xw = (1/N) * fft(x_c_t,N); % rescalling the FFT with factor 1/N will give actuall rms values at the corresponding freq
% calulate magnitude of FFT
MXw = abs(Xw);
figure("Name", "Plot of function in frequency")
plot(w,MXw);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% for part f of the question
x_f_t = cos(pi*t).*(u(t+1) - u(t-1));
figure ("Name","PLot of function in time")
plot(t,x_f_t);
%calulate FFT of the function with same number of samples as in w
Xw = (1/N) * fft(x_f_t,N); % rescalling the FFT with factor 1/N will give actuall rms values at the corresponding freq
% calulate magnitude of FFT
MXw = abs(Xw);
figure("Name", "Plot of function in frequency")
plot(w,MXw);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5