Wednesday, November 28, 2012

MATLAB CODING - PART VI

Fuzzy Logic Examples using Matlab,Fuzzy Logic Modeling with Matlab,Introduction to Fuzzy Logic using MATLAB

Fuzzy Logic, which used in Artificial intelligence.It contain logical think of rules and member input and output functions. Three steps are taken to generate a fuzzy control engine:
1)Fuzzification(Using membership functions to graphically illustrate a situation)
2)Rule evaluation(purpose of fuzzy rules)
3)Defuzzification(find the crunchy or actual results)

Here we provide the examples of Fuzzy Logic and design it.In below one way you easy create the Fuzzy project using matlab tool.

In Matlab contain a fuzzy Toolbox.it simple to create an Fuzzy Logic.
1.Type fuzzy in matlab command prompt.


2.Add a input and output variables.






in coding as follows

a = newfis('my_fis');
a = addvar(a,'input','service',[0 10]);
a = addmf(a,'input',1,'poor','gaussmf',[1.5 0]);
a = addmf(a,'input',1,'good','gaussmf',[1.5 5]);
a = addmf(a,'input',1,'excellent','gaussmf',[1.5 10]);

3.Set the input variable range and corresponding input membership function ranges,same thing do in output also.



4.choose type of Mf functions.


5.Double click the mamdani for adding a rules.




in coding

ruleList=[1 1 1 1 1
1 2 2 1 1];

a = addrule(a,ruleList);

In ruleList 1st row is 1st rule.in first 3 ones are input range and output range.in 4 is and /or 5 th one is weight of the rule.

6.Finaly save that fuzzy file name on your hard disk.

Testing a Fuzzy

1. Load a my_fis.fis in matlab command window using following commands.

my_fis_mat = readfis('my_fis'); % reading fis file

2.Give the inputs.

If you have two input means give two values in one vector array.
test_data is

my_fis_mat = readfis('my_fis');
my_test = [2 1; 4 9];
out = evalfis(my_test,my_fis_mat)

in out variable contain your result of your fuzzy. Finally you got the answer.

 

No comments:

Post a Comment