Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

9. The purpose of this problem is to use MATLAB to compute the magnitude, phase,

ID: 3348871 • Letter: 9

Question

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(jo). The input part of your program will, of course, require that you specify the particular H(jo) 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): ii) h)e u() 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 co 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? Note: Problems 1-8 are each worth 10 points, problem 9a is worth 10 points, and problems 9b and 9c are together worth 10 points.

Explanation / Answer

solution for (a)

MATLABCODE:

t = 0:1/50:10-1/50; %time instant

sig_1=exp(-4.*t);%signal 1 for a=4

sig_2=exp(-4*(abs(t)));%signal 2

sig_3=t.*exp(-4.*t);%signal 3

%choose the value of x to perform operation for signal 1,2 or 3

x=sig_3; %for signal 3

Ts=mean(diff(t));

Fs=1/Ts;

y = fft(x); %fourier transform

f = (0:length(y)-1)*50/length(y); %frequency

n = length(x);

fshift = (-n/2:n/2-1)*(50/n);

yshift = fftshift(y);%for two sided spectrum

plot(fshift,abs(yshift))

title('Magnitude')

power = abs(yshift).^2/n;

plot(fshift,power)

title('Power')

phase=angle(yshift); %phase

Eg=sum(y_squared)*Fs/n;%total energy

L=0.9*(Eg);% 90 % of the total energy

df = Fs/n; % frequency increment

y_squared=abs(yshift);

%(b) for finding the cut off frequency for 90% energy

for i=1:500

E(i)=sum(y_squared(1:i))*Fs/n;

end

for i=1:500

if E(i)<=L;

out = i;

end

end

freq_Hz=(50/500)*out;%frequency in Hz.

freq_rad=freq_Hz*2*pi;%frequency in radian.

SOLUTION FOR (C):

*f we need to design a low pass filter with a certain cut off

*frequency for all the three signals, based on the total energy criterian we will choose the signal or impulse response with the highest cut-off frequency which in this case is the third impulse response signal.