Advertisement
Kestable

Min mag from b.

Sep 28th, 2023
1,230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | Science | 0 0
  1. from control.matlab import *
  2. import matplotlib.pyplot as plt
  3.  
  4. m = 100
  5. c1 = 300
  6. c2 = 100
  7. # b константу мы пока убираем в сторону и зададим диапазон b т 10 до 200
  8. # b = 10
  9. b_arr = [i for i in range(10, 201)]
  10. s = tf('s')
  11.  
  12. # наша модель теперь тоже не может зависить от константы b, мы
  13. # проинициализируем каждую модель для своего b в массиве
  14. # w = -m*s*s/(m*s*s + b*s + c)
  15.  
  16. w_arr = [-m*s*s/(m*s*s + c1 + (c2*b*s/(b*s + c2))) for b in b_arr]
  17. # print(w)
  18.  
  19. # теперь мы пройдёмся по всем моделям с разными значениями b и
  20. # запишем максимальное значение mag в отдельный список
  21. # mag, phase, omega = bode(w, dB=True)
  22.  
  23. max_mag = []
  24. for w in w_arr:
  25.     mag, phase, omega = bode(w, dB=True, plot=False)
  26.     max_mag.append(max(mag))
  27.  
  28. # теперь мы можем построить зависимость максимальной амплитуды от значения b
  29. # а так же найти значение этого b
  30. idx = max_mag.index(min(max_mag))
  31. min_mag_b = b_arr[idx]
  32. print(min_mag_b)
  33.  
  34. plt.plot(b_arr, max_mag)
  35. plt.ylabel('max_mag(b) (dB)')
  36. plt.xlabel('b (N*sec/m)')
  37. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement