Advertisement
gandalfbialy

Untitled

Apr 12th, 2025
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. x = np.linspace(0, 50, 500)
  5.  
  6. def fuzzy_comfort(x):
  7.   return np.maximum(np.minimum(np.minimum((x - 10)  / (20 - 10), 1), (40 - x) / (40 - 30)), 0)
  8.  
  9. mu_comfort = fuzzy_comfort(x)
  10. print(fuzzy_comfort(50))
  11.  
  12. # Punkty charakterystyczne
  13. points_x = [10, 20, 30, 40]
  14. points_y = fuzzy_comfort(np.array(points_x))
  15. labels = ['a (10°C)', 'b (20°C)', 'c (30°C)', 'd (40°C)']
  16.  
  17. # Rysowanie wykresu
  18. plt.figure(figsize=(10, 5))
  19. plt.plot(x, mu_comfort, label='Temperatura komfortowa', color='green')
  20. plt.scatter(points_x, points_y, color='black', zorder=5)
  21.  
  22. # Etykiety
  23. for i, label in enumerate(labels):
  24.     plt.annotate(label, (points_x[i], points_y[i] + 0.05), ha='center')
  25.  
  26. plt.title('Funkcja przynależności: Temperatura komfortowa (trapez: 10, 20, 30, 40)')
  27. plt.xlabel('Temperatura [°C]')
  28. plt.ylabel('Przynależność')
  29. plt.grid(True)
  30. plt.legend()
  31. plt.ylim(0, 1.1)
  32. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement