Guest User

Untitled

a guest
Oct 19th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. # use latex
  5. plt.rc('text', usetex=True)
  6. plt.rc('font', family='serif')
  7.  
  8. x = np.linspace(0, 2 * np.pi, 100)
  9.  
  10. plt.subplot(411)
  11. y11 = np.sin(x) * 3
  12. y12 = np.sin(4*x)
  13. y1 = y11 + y12
  14. plt.plot(x, y11, label=r"$3\sin(x)$")
  15. plt.plot(x, y12, label=r"$\sin(4x)$")
  16. plt.plot(x, y1, label=r"$3\sin(x) + \sin(4x)$")
  17. plt.title("Zero Phase")
  18. plt.legend()
  19.  
  20. plt.subplot(412)
  21. y21 = np.sin(0.3 + x) * 3
  22. y22 = np.sin(0.3 + 4*x)
  23. y2 = y21 + y22
  24. plt.plot(x, y21, label=r"$3\sin(x+0.3)$")
  25. plt.plot(x, y22, label=r"$\sin(4x+0.3)$")
  26. plt.plot(x, y2 , label=r"$3\sin(x+0.3) + \sin(4x+0.3)$")
  27. plt.title("Phase = 0.3")
  28. plt.legend()
  29.  
  30. plt.subplot(413)
  31. y31 = np.sin(0.3*1 + x) * 3
  32. y32 = np.sin(0.3*4 + 4*x)
  33. y3 = y31 + y32
  34. plt.plot(x, y31, label=r"$3\sin(x+0.3)$")
  35. plt.plot(x, y32, label=r"$\sin(4x+0.3*4)$")
  36. plt.plot(x, y3 , label=r"$3\sin(x+0.3) + \sin(4x+0.3*4)$")
  37. plt.title("Phase = 0.3$\omega$")
  38. plt.legend()
  39.  
  40. plt.subplot(414)
  41. plt.plot(x, y1, label='Zero Phase')
  42. plt.plot(x, y2, label='Phase = 0.3')
  43. plt.plot(x, y3, label='Phase = 0.3$\omega$')
  44. plt.title("Compare three function above")
  45. plt.legend()
  46.  
  47. plt.show()
Add Comment
Please, Sign In to add comment