• API
• FAQ
• Tools
• Archive
daily pastebin goal
48%
SHARE
TWEET

# Untitled

a guest Mar 26th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import matplotlib.pyplot as plt
2. import numpy as np
3. import math
4. y0 = 5           #temp poczatakowa
5. a = 1.5
6. T = 8
7. h = 0.01
8. y_set = 22           # t*  temp zadane
9. u_max = 70
10. u_min = 10
11. M = 0.3
12.
13. def fu(e):
14.     if (e >= M):
15.         return u_max
16.     elif (e < M and e >= -M):
17.         return y_set
18.     elif (e < -M):
19.         return u_min
20.
21. t = np.arange(0, T, h)
22. y = np.empty(t.size)
23. us = np.empty(t.size)
24. es = np.empty(t.size)
25.
26. y[0] = y0
27. us[0] = y_set
28. es[0] = y_set - y[0]
29.
30. for i in range(0, t.size-1):
31.     es[i+1] = y_set - y[i]
32.     us[i + 1] = fu(es[i+1])
33.     y[i + 1] = y[i] + h * ((us[i] - y[i])/a)
34.
35. plt.figure(1)
37. plt.subplot(311)
38. plt.xlabel("t")
39. plt.ylabel("e(t)")
40. plt.plot(t, es, 'o-', markersize=1)
41. # plt.hlines(0,0, T,'r','dashed')
42. #plt.axis([20, 100, -20, 50])
43.
44.
45. plt.subplot(312)
46. plt.plot(t, y, 'r-', markersize=1)
47. plt.xlabel("t")
48. plt.ylabel("y(t)")
49. # plt.hlines(y_set + M,0, T,'y' ,'dashed')
50. # plt.hlines(y_set, 0, T, 'b', 'dashed')
51. # plt.hlines(y_set - M,0, T,'y' ,'dashed')
52. # plt.axis([0, 100, 120, 200])
53.
54.
55. plt.subplot(313)
56. plt.plot(t, us, 'r-', markersize=1)
57. plt.xlabel("t")
58. plt.ylabel("u(t)")
59.
60. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top