Created
May 17, 2021 05:06
-
-
Save JustinSDK/c24b8bf8f3b44ae368b0381998e3436c to your computer and use it in GitHub Desktop.
時域與頻域
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| freq = 10 # 頻率 | |
| stop = .25 # 取樣範圍為 0 ~ stop | |
| sample_rate = 800 # 取樣率,單位 x 取樣幾次 | |
| x = np.linspace(0, stop, int(stop * sample_rate), endpoint = False) | |
| z1 = np.sin(freq * 2 * np.pi * x) # 頻率 10 | |
| z2 = np.sin(3 * freq * 2 * np.pi * x) / 2 # 頻率 30 | |
| z3 = np.sin(4 * freq * 2 * np.pi * x) / 5 # 頻率 40 | |
| z4 = np.sin(8 * freq * 2 * np.pi * x) / 3 # 頻率 80 | |
| zero = np.zeros(z1.size) | |
| ax = plt.axes(projection='3d') | |
| ax.plot(x, zero, z1 + z2 + z3 + z4) | |
| ax.plot(x, (zero + freq), z1) | |
| ax.plot(x, (zero + 3 * freq), z2) | |
| ax.plot(x, (zero + 4 * freq), z3) | |
| ax.plot(x, (zero + 8 * freq), z4) | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment