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

i need the exact correct matlab codes for the solution of the question written b

ID: 3345122 • Letter: I

Question

i need the exact correct matlab codes for the solution of the question written below, please try to write the codes for each step seperately..



(A) Find the Discrete Fourier Transform of f(x) and g(x) for n=8 by using MatLab.

(B) Plot the absolute value of the Discrete Fourier coefficients for both functions. What is the relation between two plots? Explain.
(You need to use >>plot(abs( )) command for this.)

(C) Find the relation between the Fourier coefficients of f(x) and g(x). Explain your answer.

Explanation / Answer

% Number Array (0, 1, 2, ... , 7)

x = 0:7;

% Delta (x)

f = [1 0 0 0 0 0 0 0];

% Delta (x - 5*2*pi/6) in discrete time will have samples

% at [0:7] give by sinc function (resampling)

g = sinc(x - 5*2*pi/6);

% DFT (Use FFT in Matlab for DFT)

F = fft(f, 8);

G = fft(g, 8);

% plot real parts

figure(1);

plot(real(F), 'b'); hold on;

plot(real(G), 'r');

% plot imag parts

figure(2);

plot(imag(F), 'b'); hold on;

plot(imag(G), 'r');

% plot the angle

figure(3);

plot(angle(F), 'b'); hold on;

plot(angle(G), 'r');

% plot absolute values

figure(4);

plot(abs(F), 'b'); hold on;

plot(abs(G), 'r');