Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. # Set scale
  5. # Set sequences
  6. n = np.arange(-1, 6)
  7. x = lambda n: ((1 / 2) ** n) * (n >= 0) * (n <= 3)
  8. y = lambda n: ((1 / 4) ** (n - 1)) * (n >= 0) * (n <= 5)
  9.  
  10. # Part a
  11. # plt.stem(n, x(n), markerfmt="k.", linefmt="k", basefmt="k")
  12. # plt.title(r"Signal x[n] = $(1/2)^n$, for 0$\leq$n$\leq$3")
  13. # plt.xlabel(r"Index n where 0$\leq$n$\leq$3")
  14. # plt.xticks(n)
  15. # plt.ylabel("Amplitude")
  16.  
  17. # plt.show()
  18.  
  19. # plt.stem(n, y(n), markerfmt="k.", linefmt="k", basefmt="k")
  20. # plt.title(r"Signal y[n] = $(1/4)^{n-1}$, for 0$\leq$n$\leq$5")
  21. # plt.xlabel(r"Index n where 0$\leq$n$\leq$5")
  22. # plt.xticks(n)
  23. # plt.ylabel("Amplitude")
  24.  
  25. # plt.show()
  26.  
  27. # Part B
  28. plt.stem(n, x(n) * y(n), markerfmt="k.", linefmt="k", basefmt="k")
  29. plt.title(r"Signal x[n]y[n], for 0$\leq$n$\leq$5")
  30. plt.xlabel(r"Index n where 0$\leq$n$\leq$5")
  31. plt.xticks(n)
  32. plt.ylabel("Amplitude")
  33.  
  34. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement