Fill This Form To Receive Instant Help
Homework answers / question archive / Do the following questions with Matlab code
Do the following questions with Matlab code.
The Discrete Fourier Transform & Filtering
Implement the matrix-vector form of this discrete Fourier transform.
To do this, write two MATLAB functions x_jw=myfft(x_n) and x_n=myifft(x_jw) which must
reside in their own MATLAB files: myfft.m and myifft.m respectively. The function x_jw=myfft(x_n)
implements the discrete fourier transform by computing the matrix Ww and multiplying this matrix times
the signal, x_n, which is assumed to be a column vector. The result is a column vector which 1s the discrete
Fourier transform of the input, x_jw. The function x_n=myifft(x_jw) implements the inverse discrete
Fourier transform by computing the matrix W 4, and multiplying this matrix times the signal, x_jw,
which is assumed to be a column vector. The result is a column vector which is the inverse discrete Fourier
transform of the input, x_n.
Test your DFT function using a MATLAB script (name it as myp.m)
1. Generate a sinusoidal sequence z[n] = cos(Zn) 0 <n < N —1 where N = 6.
2. Compute the DFT of x[n], X[k].
3. Compute the IDFT of X[k], x[n].
4. Compute the sum of the point-by-point errors in the reconstruction: e = ∑Nn=0|x[n] – x[x]|.
If e >10-15 you have a bug in your code, find it and fiz it!
1. Turn in your MATLAB code consisting of printouts of myfft.m, myifft.m, and myp.m.
2. Using subplot() to generate a 3x1 matrix of plots, show the input signal x[n] from (1), the magnitude
response of DFT X[k] from] (2) and the phase response of the DFT from (2) &{k]. Note: You may
consider rounding the DFT values to their 6th digit of precision to prevent numerical instability, 1e.,
0.12345678... rounds to 0.123457.
3. Explain the following: For each index k, explain the (possibly complex) observed value of the DFT,
X[k], in terms of the magnitude and phase of the complex number (there are 5 such numbers).
4. Change the value of N such that N = 7 and use subplot() to generate a 2x1 matrix of plots showing the
input signal x[n] from (1) the magnitude response of the DFT X[k] from (2) and the phase response
of the DFT from (2) O{k]. This DFT should look different!
5. Explain why the DFT from steps (2) and (4) are different.
6. Change the phase of x{n] by generating a new signal x[n] = cos(4(n- 1) O<n<N-1
where N = 6 and recompute the DFT.
7. (10pts) Using subplot() to generate a 3x1 matrix of plots, show the input signal x{n] from (1), the
magnitude response of the DFT |X[k]| from (2) and the phase response of the DFT from (2) &k).
8. Explain why the DFT from steps (2) and (7) are different.
g. For a sinusoidal sequence x[n] = cos(n) 0 <n<N
Determine if there is a value for N Which makes the magnitude response X[k] zero everywhere except
for two indices of k as in Task 1, step (2). Write a paragraph explaining your solution and show a plot
of your results.