AIM: Write a program in Lisp to demonstrate that a fuzzy system is a structured numerical estimator-using example of controlling an inverted pendulum.
Post by: Sohrab Vakharia
(Enter two strings for angle of pendulum θ and angular velocity Δθ. Convert them into strings of fuzzy using five fuzzy set values NM (Negative medium), NS (Negative Small), ZE(Zero), PS (Positive Small) and PM ( Positive Medium). Apply FAM rules to find the output values v, the current to the motor control of the pendulum to each input set of (θ, Δθ). Create a string of fuzzy output values of the current.)
Source Code:
Output:
Post by: Sohrab Vakharia
(Enter two strings for angle of pendulum θ and angular velocity Δθ. Convert them into strings of fuzzy using five fuzzy set values NM (Negative medium), NS (Negative Small), ZE(Zero), PS (Positive Small) and PM ( Positive Medium). Apply FAM rules to find the output values v, the current to the motor control of the pendulum to each input set of (θ, Δθ). Create a string of fuzzy output values of the current.)
Source Code:
(defun FAM (angpen anguvel)
(cond
( ( equal angpen "NM")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "PM"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
( ( equal angpen "NS")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "PS"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
( ( equal angpen "ZE")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "ZE"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
( ( equal angpen "PS")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "NS"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
( ( equal angpen "PM")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "NM"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
)
)
(cond
( ( equal angpen "NM")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "PM"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
( ( equal angpen "NS")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "PS"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
( ( equal angpen "ZE")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "ZE"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
( ( equal angpen "PS")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "NS"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
( ( equal angpen "PM")
(block blkone
( cond
( ( equal anguvel "NM") nil)
( ( equal anguvel "NS") nil)
( ( equal anguvel "ZE") (print "NM"))
( ( equal anguvel "PS") nil)
( ( equal anguvel "PM") nil)
)
)
)
)
)
Output:
0 comments:
Confused? Feel free to ask
Post a Comment