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

DTFT Num Sim1

This document contains Python code that generates a decaying exponential function over 500 time indices, takes its discrete-time Fourier transform (DTFT) using two different methods, and plots the amplitude spectra of both DTFT results. The code defines the exponential decay parameter a, generates the time domain function, and computes the DTFT using a closed-form expression and a direct summation approach, plotting the amplitude spectra of both for comparison.

Uploaded by

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

DTFT Num Sim1

This document contains Python code that generates a decaying exponential function over 500 time indices, takes its discrete-time Fourier transform (DTFT) using two different methods, and plots the amplitude spectra of both DTFT results. The code defines the exponential decay parameter a, generates the time domain function, and computes the DTFT using a closed-form expression and a direct summation approach, plotting the amplitude spectra of both for comparison.

Uploaded by

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

# -*- coding: utf-8 -*"""

Created on Fri Dec 12 21:28:50 2014


@author: Anish
"""
import os
os.system('cls')
import numpy as np
N = 500
nvec = np.linspace(0, N, num=N)
a = 0.5
x_n = (a)**nvec
plot(nvec,x_n,label='Function x[n]')
plt.xlabel('Time Index')
plt.ylabel('Function')
legend(bbox_to_anchor=(.5, .9), loc=1, borderaxespad=0.)
# DTFT
w = np.linspace(0,2*pi,num = 60)
x_w = (1-a**(N+1)*exp(-1j*w*(N+1)))/(1-a*exp(-1j*w))
figure(2)
plot(w,np.abs(x_w),'o',label='Amplitude Spectrum 1')
#plot(w,np.angle(x_w),label='Phase Spectrum')
plt.xlabel('Digital Frequency (radians)')
x_num = [0]*60
ix = 0;
for wx in w:
x_num[ix] = sum((a*exp(-1j*wx))**nvec)
ix = ix +1;
mag_x = np.abs(x_num)
plot(w,mag_x,label='Amplitude Spectrum 2')
legend(bbox_to_anchor=(.5, .9), loc=1, borderaxespad=0.)

You might also like