Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. zad1
  2. import numpy as np
  3. import matplotlib.pylab as plt
  4.  
  5. def wartosc(f,x=0):
  6. return eval(f,{'x':x})
  7.  
  8. wielomian = 'x**2+3*x*(-1/27)+0.2'
  9. x=np.array([1,2,3])
  10. y=np.array([1,3,8])
  11. z=y+0
  12. for i in range(0,len(x)):
  13. z[i]=wartosc(wielomian,x[i])
  14.  
  15. plt.plot(x,y, "ro", ms=10)
  16. plt.plot(x,z,lw=2)
  17. plt.xlim(0,4)
  18. plt.show()
  19.  
  20. zad2
  21. import numpy as np
  22. from scipy import signal
  23. import matplotlib.pyplot as plt
  24.  
  25. t=np.linspace(0,4,1000, endpoint=False)
  26. tp=signal.square(np.pi*t)
  27.  
  28. ts=1.28*(np.sin(np.pi*t)+(1/3)*np.sin(np.pi*3*t)+(1/5)*np.sin(np.pi*5*t)+(1/7)*np.sin(np.pi*7*t)+(1/9)*np.sin(np.pi*9*t)+(1/11)*np.sin(np.pi*11*t)+(1/13)*np.sin(np.pi*13*t)+(1/15)*np.sin(np.pi*15*t)+(1/17)*np.sin(np.pi*17*t)+(1/19)*np.sin(np.pi*19*t)+(1/21)*np.sin(np.pi*21*t))
  29.  
  30. plt.plot(t,tp)
  31. plt.plot(t,ts)
  32. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement