Skip to content

Instantly share code, notes, and snippets.

@zhu-yifang
Created September 23, 2022 16:17
Show Gist options
  • Save zhu-yifang/6518a3084a8337d5cce0d974c310e367 to your computer and use it in GitHub Desktop.
Save zhu-yifang/6518a3084a8337d5cce0d974c310e367 to your computer and use it in GitHub Desktop.
import matplotlib.pylab as plt
import numpy as np
A = 0.8
f0 = 1000
phi = np.pi / 2
fs = 44100
t = np.arange(-0.002, 0.002, 1.0 / fs)
x = A * np.cos(2 * np.pi * f0 * t + phi)
plt.plot(t, x)
plt.axis([-0.002, 0.002, -0.8, 0.8])
plt.xlabel('time')
plt.ylabel('amplitude')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment