0% found this document useful (0 votes)
31 views1 page

Function-Latihan DFT

This document defines a function that computes the discrete Fourier transform (DFT) of a finite-duration sequence. The function takes in an N-point sequence xn and returns the DFT coefficients Xk over 0 <= k <= N-1. It creates the necessary row vectors n and k, computes the DFT matrix using the WN factor, and returns the DFT coefficients Xk by multiplying the sequence xn with the DFT matrix.

Uploaded by

qnttt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views1 page

Function-Latihan DFT

This document defines a function that computes the discrete Fourier transform (DFT) of a finite-duration sequence. The function takes in an N-point sequence xn and returns the DFT coefficients Xk over 0 <= k <= N-1. It creates the necessary row vectors n and k, computes the DFT matrix using the WN factor, and returns the DFT coefficients Xk by multiplying the sequence xn with the DFT matrix.

Uploaded by

qnttt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

function [Xk] = dft(xn,N)

% Computes Discrete Fourier Transform


% -----------------------------------
% [Xk] = dft(xn,N)
% Xk = DFT coeff. array over 0 <= k <= N-1
% xn = N-point finite-duration sequence
% N = Length of DFT
%
n = [0:1:N-1]; % row vector for n
k = [0:1:N-1]; % row vector for k
WN = exp(-j*2*pi/N); % Wn factor
nk = n'*k; % create a N by N
matrix of nk values
WNnk = WN .^ nk; % DFT matrix
Xk = xn * WNnk; % row vector for DFT
coefficients

x = [1/3,1/3,1/3, zeros(1,5)];
N=8;
X=dft(x,N);
magX=abs(X), phaX=angle(X)*180/pi
subplot(211); stem (magX); title('Magnitude of
the DFT: N=8')
xlabel('k');ylabel ('|X(k)|')
subplot(212); stem (phaX); title('Angle of the
DFT: N=8')
xlabel('k');ylabel ('Degrees|')

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy