Created
May 17, 2021 02:43
-
-
Save JustinSDK/c283a70cef65ec53deed3718ff180c5e to your computer and use it in GitHub Desktop.
NumPy 與 Matplotlib 畫正弦波
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) | |
y = np.sin(freq * 2 * np.pi * x) | |
plt.plot(x, y) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment