Function File: y = trapmf (x, params)
Function File: y = trapmf ([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 trapezoidal membership function. The argument x must be a real number or a non-empty vector of strictly increasing real numbers, and parameters a, b, c, and d must satisfy the inequalities: a < b <= c < d. None of the parameters a, b, c, d are required to be in the domain x. The minimum and maximum values of the trapezoid are assumed to be 0 and 1.

The parameters [a b c d] correspond to the x values of the corners of the trapezoid:

       1-|     --------
         |    /        \
         |   /          \
         |  /            \
       0-----------------------
            a   b      c   d

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

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

Demonstration 1

The following code

 x = 0:100;
 params = [-1 0 20 40];
 y1 = trapmf(x, params);
 params = [20 40 60 80];
 y2 = trapmf(x, params);
 params = [60 80 100 101];
 y3 = trapmf(x, params);
 figure('NumberTitle', 'off', 'Name', 'trapmf demo');
 plot(x, y1, 'r;params = [-1 0 20 40];', 'LineWidth', 2)
 hold on;
 plot(x, y2, 'b;params = [20 40 60 80];', 'LineWidth', 2)
 hold on;
 plot(x, y3, 'g;params = [60 80 100 101];', 'LineWidth', 2)
 ylim([-0.1 1.2]);
 xlabel('Crisp Input Value', 'FontWeight', 'bold');
 ylabel('Degree of Membership', 'FontWeight', 'bold');
 grid;

Produces the following figure

Figure 1

Package: fuzzy-logic-toolkit