Sie sind auf Seite 1von 3

1

LAB 2
Creating membership functions
TAKS 1
Learning outcomes
Having learned how to use the MATLAB package and its functions in LAB 1, you
will now be able to write a MATLAB code that can produce a membership function.

Having learned how to use the MATLAB package and its functions, we can now start
writing a simple code to produce a function that can calculate a degree of membership for
a given figure x. As we have learned that there are many membership functions, which
can take (almost) any form, we will be exploring some of them as follows:

Gaussian Membership function (see lecture notes for details)


function mem=gausmem(x,v,s)
%
%
%
%

Assume that x is defined in [-5,5]


NO fuzzification factor
v: centre (e.g., 0)
s: width (e.g., 2)

g1=(x-v)/s;
g2=abs(g1);
g3=exp(-g2.^2)
%plot membership function for a given x in [-5,5]
x=-5:0.5:5;
g1=(x-v)/s;
g2=abs(g1);
g3=exp(-g2.^2);
plot(x,g3)

Investigate how values of the parameters, in particular s, affect shape of this


membership function.

Now, lets do it with fuzzification factor (f)

function mem=gausmemf(x,v,s,f)
%
%
%
%

Assume that x is defined in [-5,5]


f: fuzzification factor (e.g., 2)
v: centre (e.g., 0)
s: witdh (e.g., 2)

g1=(x-v)/s;
g2=abs(g1);
g3=exp(-g2.^f)
%plot membership function for a given x in [-5,5]
x=-5:0.5:5;
g1=(x-v)/s;
g2=abs(g1);
g3=exp(-g2.^f);
plot(x,g3)

Investigate how values of the parameters, in particular s and f, affect shape of this
membership function when any of them or both are changed.

TASK 2
Learning outcomes
You will do more experiments with different membership functions
You will now be able to repeat the experiment in TASK 1 for triangular and trapezoidal
membership functions.
You can include a similar fuzzification factor in triangular membership function and
generalize it as in TASK 1.
As you can see from the figures, triangular membership function is in fact a special case
of trapezoidal membership functions when b=c. In this case, creating a trapezoidal
membership function will be enough to represent triangular membership function.
Students are expected to write a simple code to generate degrees of membership for these
two membership functions

Triangular Membership Function

Trapezoidal Membership Function

Das könnte Ihnen auch gefallen