0% found this document useful (0 votes)
194 views

Python DTFT Periodicity

The document contains Python code that generates and plots the time and frequency domain representations of a discrete time signal. It defines a signal as (0.5)^n from n=0 to n=50, plots the time domain signal, and then performs a discrete time Fourier transform to obtain the amplitude and phase spectra, plotting both for two different frequency ranges.

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)
194 views

Python DTFT Periodicity

The document contains Python code that generates and plots the time and frequency domain representations of a discrete time signal. It defines a signal as (0.5)^n from n=0 to n=50, plots the time domain signal, and then performs a discrete time Fourier transform to obtain the amplitude and phase spectra, plotting both for two different frequency ranges.

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 = 50
nvec = np.linspace(0, 10, num=N)
x_n = (0.5)**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 = N)
x_w = exp(1j*w)/(exp(1j*w)-0.5)
figure(2)
plot(w,abs(x_w),label='Amplitude Spectrum')
plot(w,np.angle(x_w),label='Phase Spectrum')
plt.xlabel('Digital Frequency (radians)')
legend(bbox_to_anchor=(.5, .9), loc=1, borderaxespad=0.)

w = np.linspace(0,6*pi,num = N)
x_w = exp(1j*w)/(exp(1j*w)-0.5)
figure(3)
plot(w,abs(x_w),label='Amplitude Spectrum')
plot(w,np.angle(x_w),label='Phase Spectrum')
plt.xlabel('Digital Frequency (radians)')
legend(bbox_to_anchor=(.5, .9), loc=1, borderaxespad=0.)

You might also like