Use the Matlab x(n) = n 0 lessthanorequalto n lessthanorequalto = 1 0 lessthanor
ID: 2081862 • Letter: U
Question
Use the Matlab x(n) = n 0 lessthanorequalto n lessthanorequalto = 1 0 lessthanorequalto k lessthanorequalto M = 1 Determine the M-point DFT X (k) of the following N-point sequence x(n). Plot x (n), magnitude of the DFT, phase of the DFT using subplot and stem commands. Given M=16, N=8. x(m) = {m/8 0 lessthanorequalto m lessthanorequalto M = 1 0, otherwise Compute IDFT of the following M-point DFT sequence and plot original DFT sample, real part of IDFT, and imaginary part of IDFT using subplot and stem command. Given N=13, M=8, 0 lessthanorequalto n lessthanorequalto N = 1 x(n) = cos (2 m times 3/16) Generate the length-16 cosine sequence x(n). Compute its 16-point DFT and 512-point DFT. Plot the magnitudes of the two DFTs in one graph using hold on function To plot (he two graphs, you need to match the x-axes (0:1/16:1-1/16 and 0:1/512:1-1/512)Explanation / Answer
clc;
close all;
clear all;
% QUESTION 1
N = 8;
M = 16;
n = 0:1:N-1;
k = 0:1:M-1;
xn = n;
Xk = fft(xn,M);
figure
subplot(3,1,1);
stem(n,xn);
title('Original sequence');
xlabel('n');
ylabel('x(n)');
subplot(3,1,2);
stem(k,abs(Xk));
title('Magnitude plot');
xlabel('k');
ylabel('Mag');
subplot(3,1,3);
stem(k,angle(Xk));
title('Phase plot');
xlabel('k');
ylabel('Phase');
% QUESTION 2
N = 13;
M = 8;
n = 0:1:N-1;
m = 0:1:M-1;
Xm = m/8;
xn = ifft(Xm,N);
figure
subplot(3,1,1);
stem(m,Xm);
title('Original DFT');
xlabel('m');
ylabel('X(m)');
subplot(3,1,2);
stem(n,real(xn));
title('Real value plot');
xlabel('n');
ylabel('Value');
subplot(3,1,3);
stem(n,imag(xn));
title('Imaginary plot');
xlabel('n');
ylabel('Value');
% QUESTION 3
N = 16;
M1 = 16;
M2 = 512;
n = 0:1:N-1;
m1 = 0:1:M1-1;
m2 = 0:1:M2-1;
xn = cos(2*pi*n*3/16);
Xk_16 = fft(xn,M1);
Xk_512 = fft(xn,M2);
figure
subplot(3,1,1);
stem(n,xn);
title('Original DFT');
xlabel('m');
ylabel('X(m)');
subplot(3,1,2);
plot(m1,abs(Xk_16),'r');
a(1,:) = axis;
hold on
%subplot(3,1,3);
plot(m2,abs(Xk_512),'m');
a(2,:) = axis;
axis([min(a(:,1)) max(a(:,2)) min(a(:,3)) max(a(:,4))]);
title('absolute magnitude: 16/512 point');
xlabel('m1/m2');
ylabel('Value');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.