This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Membership Function Gallery

This example shows how to display 11 membership functions supported in the Fuzzy Logic Toolbox�.

Define membership functions.

mf = [...
    fismf('trapmf',[-19 -17 -12 -7]) ...
    fismf('gbellmf',[3 4 -8]) ...
    fismf('trimf',[-9 -1 2]) ...
    fismf('gaussmf',[3 5]) ...
    fismf('gauss2mf',[3 10 5 13]) ...
    fismf('smf',[11 17]) ...
    fismf('zmf',[-18 -10]) ...
    fismf('psigmf',[2 -11 -5 -4]) ...
    fismf('dsigmf',[5 -3 1 5]) ...
    fismf('pimf',[0 7 11 15]) ...
    fismf('sigmf',[2 15]) ...
    ];

For more information on the different membership functions and their parameters, see their respective function reference pages.

Evaluate the membership functions.

x = linspace(-20,20,201);
y = evalmf(mf,x);

Plot the evaluated membership functions with labels.

subplot(2,1,1);
plot(x,y(1:6,:)');
axis([min(x) max(x) 0 1.2]);
text((mf(1).Parameters(2)+mf(1).Parameters(3))/2,1.1,mf(1).Type,...
    'horizon','center');
text(mf(2).Parameters(3),1.1,mf(2).Type,...
    'horizon','center');
text(mf(3).Parameters(2),1.1,mf(3).Type,...
    'horizon','center');
text(mf(4).Parameters(2),1.1,mf(4).Type,...
    'horizon','center');
text((mf(5).Parameters(2)+mf(5).Parameters(4))/2,1.1,mf(5).Type,...
    'horizon','center');
text(mf(6).Parameters(2), 1.1,mf(6).Type,...
    'horizon','center');
h_gca = gca;
h_gca.XTick = [];

subplot(2,1,2);
plot(x,y(7:11,:)');
axis([min(x) max(x) 0 1.2]);
text(mf(7).Parameters(1),1.1,mf(7).Type,...
    'horizon','center');
text((mf(8).Parameters(2)+mf(8).Parameters(4))/2,1.1,mf(8).Type,...
    'horizon','center');
text((mf(9).Parameters(2)+mf(9).Parameters(4))/2,1.1,mf(9).Type,...
    'horizon','center');
text((mf(10).Parameters(2)+mf(10).Parameters(3))/2,1.1,mf(10).Type,...
    'horizon','center');
text(mf(11).Parameters(2),1.1,mf(11).Type,...
    'horizon','center');
h_gca =  gca;
h_gca.XTick = [];

Related Topics