Function File: y = pimf (x, params)
Function File: y = pimf ([x1 x2 ... xn], [a b c d])

For a given domain x and parameters params (or [a b c d]), return the corresponding y values for the pi-shaped membership function.

The argument x must be a real number or a non-empty vector of real numbers, and a, b, c, and d must be real numbers, with a < b <= c < d. This membership function satisfies:

        0                             if x <= a
        2 * ((x - a)/(b - a))^2       if a < x <= (a + b)/2
        1 - 2 * ((x - b)/(b - a))^2   if (a + b)/2 < x < b
f(x) =  1                             if b <= x <= c
        1 - 2 * ((x - c)/(d - c))^2   if c < x <= (c + d)/2
        2 * ((x - d)/(d - c))^2       if (c + d)/2 < x < d
        0                             if x >= d

which always returns values in the range [0, 1].

To run the demonstration code, type demo('pimf') at the Octave prompt.

See also: dsigmf, gauss2mf, gaussmf, gbellmf, psigmf, sigmf, smf, trapmf, trimf, zmf.

Demonstration 1

The following code

 x = 0:255;
 params = [70 80 100 140];
 y1 = pimf(x, params);
 params = [50 75 105 175];
 y2 = pimf(x, params);
 params = [30 70 110 200];
 y3 = pimf(x, params);
 figure('NumberTitle', 'off', 'Name', 'pimf demo');
 plot(x, y1, 'r;params = [70 80 100 140];', 'LineWidth', 2)
 hold on;
 plot(x, y2, 'b;params = [50 75 105 175];', 'LineWidth', 2)
 hold on;
 plot(x, y3, 'g;params = [30 70 110 200];', 'LineWidth', 2)
 ylim([-0.1 1.1]);
 xlabel('Crisp Input Value', 'FontWeight', 'bold');
 ylabel('Degree of Membership', 'FontWeight', 'bold');
 grid;

Produces the following figure

Figure 1

Package: fuzzy-logic-toolkit