Python how to plot graph sine wave

前端 未结 9 1235
死守一世寂寞
死守一世寂寞 2021-02-01 07:11

I have this signal :

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)

How can I plot a

9条回答
  •  醉梦人生
    2021-02-01 07:41

    Yet another way to plot the sine wave.

    import numpy as np
    import matplotlib
    matplotlib.use('TKAgg') #use matplotlib backend TKAgg (optional)
    import matplotlib.pyplot as plt
    
    t = np.linspace(0.0, 5.0, 50000)       # time axis
    sig = np.sin(t)
    plt.plot(t,sig)
    

提交回复
热议问题