我有这个信号:
from math import*
Fs=8000
f=500
sample=16
a=[0]*sample
for n in range(sample):
a[n]=sin(2*pi*f*n/Fs)
如何绘制图表(这个正弦波)?
并将 xlabel 的名称创建为“电压(V)”,将 ylabel 创建为“样本(n)”
什么代码可以做到这一点?
- Setting the
x-axis
with np.arange(0, 1, 0.001)
gives an array from 0 to 1 in 0.001 increments.
-
x = np.arange(0, 1, 0.001)
返回 1000 个从 0 到 1 的点的数组,并且y = np.sin(2*np.pi*x)
您将得到采样 1000 次从 0 到 1 的正弦波
我希望这个能帮上忙:
import matplotlib.pyplot as plt
import numpy as np
Fs = 8000
f = 5
sample = 8000
x = np.arange(sample)
y = np.sin(2 * np.pi * f * x / Fs)
plt.plot(x, y)
plt.xlabel('sample(n)')
plt.ylabel('voltage(V)')
plt.show()
P.S.:为了舒适的工作,您可以使用Jupyter 笔记本 https://jupyter.org/.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)