In: Electrical Engineering
9. The purpose of this problem is to use MATLAB to
compute the magnitude, phase, and total
energy of a Fourier transform.
a) Develop a MATLAB routine to plot the magnitude and phase of a
given Fourier
transform H(jω). The input part of your program will, of course,
require that you
specify the particular H(jω) of interest, but, once this is done,
your program should not
depend on the Fourier transform specified. You will need to select
an appropriate
range of frequencies for these plots. Test your program using the
following three
signals for a = 4 (plot all three using the same range of
frequencies):
i) h(t) = e-at u(t)
ii) h(t) = e-a|t|
iii) h(t) = te-at u(t)
b) Extend the MATLAB routine that you developed in part a) to find
the approximate
total energy in each of the signals, as well as to find the
approximate frequency ω in
rad/sec below which 90% of the total signal energy is
contained.
c) Suppose you wanted to design a simple low-pass filter with a
specified cutoff
frequency. Assuming that you could choose the desired value of a
and based on the
total energy criterion alone, which impulse response would you
choose? Why?
%Part a Solution
clc;
clear all;
close all;
a=4;
F=50;
t = 0:1/F:10-1/F; %time instant
signal_1=exp(-a.*t);%signal 1
signal_2=exp(-a*(abs(t)));%signal 2
signal_3=t.*exp(-a.*t);%signal 3
Ts=mean(diff(t));
Fs=1/Ts;
%%Choose the signal
signal=signal_1;
a = fft(signal); %fourier transform of signal 1
freq = (0:length(a)-1)*50/length(a); %frequency
l = length(signal);
fshift = (-l/2:l/2-1)*(50/l);
yshift = fftshift(a);%for two sided spectrum
plot(fshift,abs(yshift))
title('Magnitude')
power = abs(yshift).^2/l;
plot(fshift,power)
title('Power')
phase=angle(yshift); %phase
%%Part b Solution
y_squared=abs(yshift);
Et=sum(y_squared)*Fs/l;%total energy
Eg=0.9*(Et);% 90 % of the total energy
df = Fs/l; % frequency increment
for i=1:500
E(i)=sum(y_squared(1:i))*Fs/l;
end
for i=1:500
if E(i)<=Eg;
out = i;
end
end
freq_Hz=(50/500)*out;%frequency in Hz.
%%Part c Solution
To design a simple low pass filter with a specified cut off frequency based on the total energy criterian alone we will choose the third signal because the impulse response of third signal has the highest cut-off frequency