Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import skfuzzy as fuzz
- import matplotlib.pyplot as plt
- import ipdb
- def trimf(x, abc):
- a, b, c = abc
- y = np.zeros(len(x))
- left_side_eq = (1/(b-a))*(x-a)
- right_side_eq = (1/(c-b))*(-x+c)
- y = np.minimum(left_side_eq,right_side_eq)
- y = np.maximum(y,0)
- return y
- def trapmf(x,abcd):
- a, b, c, d = abcd
- left_side_eq = (1/(b-a))*(x-a)
- right_side_eq = (1/(d-c))*(-x+d)
- y = np.minimum(left_side_eq,right_side_eq)
- y = np.maximum(y,0)
- y = np.minimum(y,1)
- return y
- x = np.linspace(0,10,110)
- mfx = trimf(x, [0, 5, 10])
- plt.plot(x,mfx)
- plt.show()
- mfx = trapmf(x, [0, 3, 7 , 10])
- plt.plot(x,mfx)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement