In MATLAB, we can calculate the Discrete Time Fourier Transform (DTFT) of a discrete sequence x(n)
using the fft
function. The DTFT of x(n)
can be obtained as follows:
main.m175 chars5 lines
Here, N
is the length of the input sequence x
. The fft
function calculates the FFT of the sequence x
, which is the DTFT of x
sampled at N
frequencies. The w
vector contains the frequencies at which the DTFT is sampled.
Note that the DTFT is a continuous function of frequency and hence, it is represented by a continuous curve in the frequency domain. To plot the magnitude and phase of the DTFT, we can use the plot
function as follows:
main.m294 chars14 lines
This will plot the magnitude and phase of the DTFT on separate subplots.
Alternatively, we can use the freqz
function to plot the magnitude and phase of the DTFT as follows:
main.m471 chars16 lines
This will plot the magnitude and phase of the DTFT of a filter designed using the butter
function. Note that freqz
plots the normalized frequency in the range [-pi, pi]
(or [-0.5, 0.5]
cycles/sample).
gistlibby LogSnag