Main Content


Trapezoidal membership function


This function computes fuzzy membership values using a trapezoidal membership function. You can also compute this membership function using a fismf object. For more information, see fismf Object.

This membership function is related to the trimf, linsmf, and linzmf membership functions.


y = trapmf(x,params) returns fuzzy membership values computed using the following trapezoidal membership function:


To define the membership function parameters, specify params as the vector [a b c d].

Membership values are computed for each input value in x.


collapse all

Specify input values across the universe of discourse.

x = 0:0.1:10;

Evaluate membership function for the input values.

y = trapmf(x,[1 5 7 8]);

Plot the membership function.

title('trapmf, P = [1 5 7 8]')
ylabel('Degree of Membership')
ylim([-0.05 1.05])

Figure contains an axes object. The axes object with title trapmf, P = [1 5 7 8] contains an object of type line.

Input Arguments

collapse all


Membership function parameters, specified as the vector [a b c d]. Parameters b and c define the shoulders of the membership function, and a and d define its feet.

The shape of the membership function depends on the relative values of b and c.

  • When c is greater than b, the resulting membership function is trapezoidal.

  • When b is equal to c, the resulting membership function is equivalent to a triangular membership function with parameters [a b d].

  • When c is less than b, the resulting membership function is triangular with a maximum value less than 1.

Output Arguments

collapse all


Alternative Functionality

fismf Object

You can create and evaluate a fismf object that implements the trapmf membership function.

mf = fismf("trapmf",P);
Y = evalmf(mf,X);

Here, X, P, and Y correspond to the x, params, and y arguments of trapmf, respectively.

Extended Capabilities

C/C++ Code Generation

Version History

Introduced before R2006a