Beruflich Dokumente
Kultur Dokumente
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:
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)
function mem=gausmemf(x,v,s,f)
%
%
%
%
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