M-file
dft.m
function Xk = dft(x)
[N,M] = size(x);
if M ~=1, % makes sure that x is a column vector
x = x';
N = M;
end
Xk=zeros(N,1);
n = 0:N-1;
for k=0:N-1
Xk(k+1) = exp(-j*2*pi*k*n/N)*x;
end
function Xk = dft(x,N)
M=length(x);
if M>N
disp('N must be >=M')
end
xnew=[x (zeros(1,N-M))]
for k=0:1:N-1
for n=0:1:N-1
xk(k+1,n+1)=exp(-j*2*pi*k*n/N);
end
end
Xk=xk*xnew'
Program:
N=32
n=0:1:10
xn=cos(10*n*pi/11)
Xk=dft(xn,N)
%__________________________________
%plots
k=0:1:N-1;
subplot(311)
stem(n,xn,'k')
title('Sequence in time domain x(n)')
xlabel('n')
ylabel('x(n)')
subplot(312)
stem(k,abs(Xk),'r')
title('DFT of x(n)-Magnitude response')
xlabel('k')
ylabel('|X(k)|')
subplot(313)
stem(k,angle(Xk),'m')
title('DFT of x(n)-Phase response')
xlabel('k')
ylabel('<X(k)')
M-file dft.m function Xk = dft(x) [N,M] = size(x); if M ~=1, % makes sure that...
Compute the DFT for each of the foregoing signals using the
MATLAB M-file dft
(a) x[0) - 1,x[1] =0, x[2] = 1,x[3] = 0 (b) x[0] = 1, *[1] = 0, x{2) = -1, x[3) = 0 (e) x[0] = 1, x[1] = 1, x[2] = -1, x[3] = -1
Find N-point DFT of x[n]=
n=0,1,…,N-1
X[n] =
Using the periodicity of the complex exponentials, we can write
x[n] follows:
X[n] =
The DFT coefficients are
9N/2
k=0
X[k]=
N/4
k=2 and k=-2
0
else
Using the 4-point DFT/IFFT in matrix form, determine: (a) The DFT of x[n] = [1, 2, 1, 2]. (b) The IDFT of X[k] = [0, 4, 0, 4];
1. Let {X[k]}K=o be the N = 8-point DFT of the real-valued sequence x[n] = [1, 2, 3, 4]. (a) Let Y[k] = X[k]ejak + X[<k – 4 >8] be the N = 8-point DFT of a sequence y[n]. Compute y[n]. Note: Do NOT compute X[k]. (b) Let Y[k] = X*[k] be the DFT of the sequence y[n], where * denotes the conjugate. Compute the sequence y[n]. Note: Do NOT compute X[k].
-Σ rinkin + ml. Sequence c[n] is defined as c[n] x(n] = { 1,-1, 1 } as x[k] and 5-point DFT of c[n] as c[k]. (i) Calculate C[1]? 「[I] = 1-e^(-%72%pi/5)+6 alculate the 4-point DFT of sequence Your last answer was interpreted as follows: I-e + e- Incorrect answer. ii) Calculate i [] is the conjugate operator) -96 Your last answer was interpreted as follows:-i Incorrect answer.
-Σ rinkin + ml. Sequence c[n] is defined as c[n] x(n] = {...
Problem 3 20 points Let f[n]- 1,2,1,0 Use MATLAB to compute the DFT F[k] and turn in the some comments and inclilcle the answer % Compute DFT from FFT x-[1 2 1 0] N-length(x) F-fft(x,N)
Problem 3 20 points Let f[n]- 1,2,1,0 Use MATLAB to compute the DFT F[k] and turn in the some comments and inclilcle the answer % Compute DFT from FFT x-[1 2 1 0] N-length(x) F-fft(x,N)
Compute the N-point DFT of the following finite-length sequences
considered to be of length N (N is even):
1, n odd 0, n even (a) x[n] = COS Tn
ASSIGNMENT 2 (C4,_CO2, PO1) 1. Calculate DFT of the following discrete-time sequence, x(n) using DFT technique x(n) = {72,-56, 159) (C4, CO2,PO1) 2. Calculate the 8-point DFT of the following discrete-time sequence, x(n) using Decimation In Time Fast Fourier transform (DIT-FFT) algorithm. Show the sketch and label all parameters on a signal flow graph/butterfly diagram structure in your answer. (1-3<ns3 x(n) = 0 elsewhere
Please answer "b" only.
%Example code
function plotFS(m);
%m = user provided number of terms desired in the Fourier series;
%this code computes the Fourier series of the function
%f(x)=0, for -pi<= x <0,
% =cos(x) for 0<= x <pi
%generate the interval from -pi to pi with step size h;
h = pi/100;
xx1=[-pi:h:0];
xx2=[0:h:pi];
xx = [xx1, xx2];
%generate the given function f so that it can be graphed
ff = [zeros(size(xx1)), cos(xx2)];
%compute the first partial sum...
5.34. Two signals æ[n] and h[n] are given by - 3, 4, 1, 6 arn]{2, t n 0 h[n1, 1, , 0, 0} t n 0 Compute the circular convolution y[n] x[n]h[n] through direct application of the circular convolution sum a. b. Compute the 5-point transforms X k] and H[k] c. Compute Y[k] Xk] Hk, and the obtain y[n] as the inverse DFT of Y [k. Verify that the same result is obtained as in part (a)