Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- # Set scale
- # Set sequences
- n = np.arange(-1, 6)
- x = lambda n: ((1 / 2) ** n) * (n >= 0) * (n <= 3)
- y = lambda n: ((1 / 4) ** (n - 1)) * (n >= 0) * (n <= 5)
- # Part a
- # plt.stem(n, x(n), markerfmt="k.", linefmt="k", basefmt="k")
- # plt.title(r"Signal x[n] = $(1/2)^n$, for 0$\leq$n$\leq$3")
- # plt.xlabel(r"Index n where 0$\leq$n$\leq$3")
- # plt.xticks(n)
- # plt.ylabel("Amplitude")
- # plt.show()
- # plt.stem(n, y(n), markerfmt="k.", linefmt="k", basefmt="k")
- # plt.title(r"Signal y[n] = $(1/4)^{n-1}$, for 0$\leq$n$\leq$5")
- # plt.xlabel(r"Index n where 0$\leq$n$\leq$5")
- # plt.xticks(n)
- # plt.ylabel("Amplitude")
- # plt.show()
- # Part B
- plt.stem(n, x(n) * y(n), markerfmt="k.", linefmt="k", basefmt="k")
- plt.title(r"Signal x[n]y[n], for 0$\leq$n$\leq$5")
- plt.xlabel(r"Index n where 0$\leq$n$\leq$5")
- plt.xticks(n)
- plt.ylabel("Amplitude")
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement