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

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

The argument x must be a real number or a non-empty vector of strictly increasing real numbers, and parameters a, b, and c must be real numbers that satisfy a < b < c. None of the parameters a, b, and c are required to be in the domain x. The minimum and maximum values of the triangle are assumed to be 0 and 1.

The parameters [a b c] correspond to the x values of the vertices of the triangle:

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

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

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

Demonstration 1

The following code

 x = 0:100;
 params = [-1 0 50];
 y1 = trimf(x, params);
 params = [0 50 100];
 y2 = trimf(x, params);
 params = [50 100 101];
 y3 = trimf(x, params);
 figure('NumberTitle', 'off', 'Name', 'trimf demo');
 plot(x, y1, 'r;params = [-1 0 50];', 'LineWidth', 2)
 hold on;
 plot(x, y2, 'b;params = [0 50 100];', 'LineWidth', 2)
 hold on;
 plot(x, y3, 'g;params = [50 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