Main Content

evalmf

Evaluate fuzzy membership function

Description

example

y= evalmf(mfT1,x)evaluates one or more type-1 membership functions based on the input values inx, returning the membership function values.

example

[yUpper,yLower] = evalmf(mfT2,x)evaluates one or more type-2 membership function based on the input values inx, returning both the upper and lower membership function values.

Examples

collapse all

Evaluate a generalized bell-shaped membership function across a range of input values from0through10.

x = 0:0.1:10; mf = fismf("gbellmf",[2 4 6]); y = evalmf(mf,x);

Plot the evaluation.

plot(x,y) xlabel('gbellmf, P = [2 4 6]')

Figure contains an axes object. The axes object contains an object of type line.

Create a vector of three Gaussian membership functions.

mf = [fismf("gaussmf",[0.9 2.5],'Name',"low"); fismf("gaussmf",[0.9 5],'Name',"medium"); fismf("gaussmf",[0.9 7.55],'Name',"high")];

Specify the input range over which to evaluate the membership functions.

x = (-2:0.1:12)';

Evaluate the membership functions.

y = evalmf(mf,x);

Plot the evaluation results.

plot(x,y) xlabel('Input (x)') ylabel('Membership value (y)') legend("low","medium","high")

Figure contains an axes object. The axes object contains 3 objects of type line. These objects represent low, medium, high.

Create a triangular type-2 membership function.

mf = fismftype2("trimf",[5 7 9],'LowerLag',0.3,'LowerScale',0.8);

Evaluate the membership function across a range of input values from0through10.

x = 0:0.1:10; [yUpper,yLower] = evalmf(mf,x);

Plot the evaluated upper and lower MFs.

plot(x,yUpper,x,yLower) legend('Upper MF','Lower MF','Location','northwest') xlabel('Input') ylabel('Membership value')

Figure contains an axes object. The axes object contains 2 objects of type line. These objects represent Upper MF, Lower MF.

Input Arguments

collapse all

Type-1 membership function, specified as afismfobject or a vector of such objects.

Input value, specified as a scalar, vector, or 2-D matrix. Ifmfis a:

  • Singlefismfobject, then you can specifyxas a scalar, vector, or matrix

  • Vector offismfobjects, then you can specifyxas a scalar or vector

Type-2 membership function, specified as afismftype2object or a vector of such objects.

Output Arguments

collapse all

Membership value for a type-1 membership function, returned as a scalar, vector, or 2-D matrix. IfmfT1is a:

  • Singlefismfobject, thenyis a scalar, vector, or matrix with the same dimensions asx. Each element ofyis the evaluated membership value for the corresponding element ofx.

  • Vector offismfobjects, thenyis anM-by-Nmatrix, whereMandNare the lengths ofmfT1andx, respectively.y(i,j) is the evaluated value of membership functionmfT1(i) for input valuex(j).

Upper MF membership value for a type-2 membership function, returned as a scalar, vector, or 2-D matrix. IfmfT2is a:

  • Singlefismftype2object, thenyis a scalar, vector, or matrix with the same dimensions asx. Each element ofyis the evaluated membership value for the corresponding element ofx.

  • Vector offismftype2objects, thenyis anM-by-Nmatrix, whereMandNare the lengths ofmfT2andx, respectively.y(i,j) is the evaluated value of membership functionmfT2(i) for input valuex(j).

Lower MF membership value for a type-2 membership function, returned as a scalar, vector, or 2-D matrix. IfmfT2is a:

  • Singlefismftype2object, thenyis a scalar, vector, or matrix with the same dimensions asx. Each element ofyis the evaluated membership value for the corresponding element ofx.

  • Vector offismftype2objects, thenyis anM-by-Nmatrix, whereMandNare the lengths ofmfT2andx, respectively.y(i,j) is the evaluated value of membership functionmfT2(i) for input valuex(j).

Compatibility Considerations

expand all

Behavior changed in R2018b

Introduced before R2006a