Posted By

aturlapaty on 09/18/14


Tagged

signals systems


Versions (?)

Sampling from a continuous signal


 / Published in: Python
 

URL: sampler

behavior of sampler as the sampling interval changes

  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Tue Sep 16 20:13:07 2014
  4.  
  5. @author: Anish
  6. """
  7.  
  8. import os
  9. os.system('cls')
  10. import numpy as np
  11. import matplotlib.pyplot as plt
  12. #a = 2
  13. #plt.figure(1)
  14. nvec11 = np.linspace(1,500,num=500)
  15. nvec2 = nvec11/100
  16. x_t = cos(2*pi*nvec2)
  17. plt.figure(1)
  18. plt.plot(nvec2,x_t,'r')
  19.  
  20. #T = 1/1.0
  21. N = 10
  22. Nlim = 7
  23. nvec = np.linspace(1, N, num=N)
  24. nlimvec = np.linspace(0.0, Nlim-1, num=Nlim)
  25. Tvec = 2**(-nlimvec)
  26.  
  27. plt.figure(2)
  28. for tx in range(1, Nlim):
  29. nvec1 = nvec*Tvec[tx-1]
  30. x = cos(2*pi*nvec1)
  31. plt.subplot(2,3,tx)
  32. plt.stem(nvec1,x)
  33.  
  34. plt.figure(3)
  35. nvec11 = np.linspace(1,500,num=500)
  36. nvec3 = nvec11/64
  37. x_t2 = cos(2*pi*nvec3)
  38. plt.plot(nvec3,x_t2,'og')

Report this snippet  

You need to login to post a comment.