Evaluate fuzzy membership function

Evaluate a generalized bell-shaped membership function across a range of input values from `0`

through `10`

.

```
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]')
```

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")

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 from `0`

through `10`

.

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')

`mfT1`

— Type-1 membership function`fismf`

object | vector of `fismf`

objectsType-1 membership function, specified as a `fismf`

object or a vector of such objects.

`x`

— Input valuescalar | vector | 2-D matrix

Input value, specified as a scalar, vector, or 2-D matrix. If
`mf`

is a:

Single

`fismf`

object, then you can specify`x`

as a scalar, vector, or matrixVector of

`fismf`

objects, then you can specify`x`

as a scalar or vector

`mfT2`

— Type-2 membership function`fismftype2`

object | array of `fismftype2`

objectsType-2 membership function, specified as a `fismftype2`

object or a vector of such objects.

`y`

— Membership values for a type-1 membership functionscalar | vector | 2-D matrix

Membership value for a type-1 membership function, returned as a scalar,
vector, or 2-D matrix. If `mfT1`

is a:

Single

`fismf`

object, then`y`

is a scalar, vector, or matrix with the same dimensions as`x`

. Each element of`y`

is the evaluated membership value for the corresponding element of`x`

.Vector of

`fismf`

objects, then`y`

is an*M*-by-*N*matrix, where*M*and*N*are the lengths of`mfT1`

and`x`

, respectively.`y`

(*i*,*j*) is the evaluated value of membership function`mfT1`

(*i*) for input value`x`

(*j*).

`yUpper`

— Upper MF membership values for a type-2 membership functionscalar | vector | 2-D matrix

Upper MF membership value for a type-2 membership function, returned as a
scalar, vector, or 2-D matrix. If `mfT2`

is a:

Single

`fismftype2`

object, then`y`

is a scalar, vector, or matrix with the same dimensions as`x`

. Each element of`y`

is the evaluated membership value for the corresponding element of`x`

.Vector of

`fismftype2`

objects, then`y`

is an*M*-by-*N*matrix, where*M*and*N*are the lengths of`mfT2`

and`x`

, respectively.`y`

(*i*,*j*) is the evaluated value of membership function`mfT2`

(*i*) for input value`x`

(*j*).

`yLower`

— Lower MF membership values for a type-2 membership functionscalar | vector | 2-D matrix

Lower MF membership value for a type-2 membership function, returned as a
scalar, vector, or 2-D matrix. If `mfT2`

is a:

Single

`fismftype2`

object, then`y`

is a scalar, vector, or matrix with the same dimensions as`x`

. Each element of`y`

is the evaluated membership value for the corresponding element of`x`

.Vector of

`fismftype2`

objects, then`y`

is an*M*-by-*N*matrix, where*M*and*N*are the lengths of`mfT2`

and`x`

, respectively.`y`

(*i*,*j*) is the evaluated value of membership function`mfT2`

(*i*) for input value`x`

(*j*).

*Behavior changed in R2018b*

`evalmf`

now takes a `fismf`

object as an input argument rather than the type and parameters of the membership
function. Also, you can now evaluate multiple membership functions by passing an
array of `fismf`

objects to `evalmf`

. There
are differences between these approaches that require updates to your code.

Previously, you evaluated a membership function for given input values,
`x`

, by specifying the type of membership function,
`type`

, and the membership functions parameters,
`params`

.

y = evalmf(x,params,type);

Update your code to first create a `fismf`

object,
`mf`

. Then, pass this object to
`evalmf`

.

mf = fismf(type,params); y = evalmf(mf,x);

Also, previously, to evaluate multiple membership functions you called
`evalmf`

once for each membership function.

y1 = evalmf(x,params1,type1); y2 = evalmf(x,params2,type2); y3 = evalmf(x,params3,type3);

Now, you can evaluate multiple membership functions by passing an array of
`fismf`

objects to `evalmf`

.

mf1 = fismf(type1,params1); mf2 = fismf(type2,params2); mf2 = fismf(type3,params3); y = evalmf([mf1 mf2 mf3],x);

Here, `y = [y1 y2 y3]';`

A modified version of this example exists on your system. Do you want to open this version instead?

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)