evalmf
Evaluate fuzzy membership function
Description
Examples
Evaluate 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]')
Evaluate Multiple Membership Functions
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")
Evaluate Type-2 Membership Function
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')
Input Arguments
mfT1
— Type-1 membership function
fismf
object | vector of fismf
objects
Type-1 membership function, specified as a fismf
object or a vector of such objects.
x
— Input value
scalar | 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 specifyx
as a scalar, vector, or matrixVector of
fismf
objects, then you can specifyx
as a scalar or vector
mfT2
— Type-2 membership function
fismftype2
object | array of fismftype2
objects
Type-2 membership function, specified as a fismftype2
object or a vector of such objects.
Output Arguments
y
— Membership values for a type-1 membership function
scalar | 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, theny
is a scalar, vector, or matrix with the same dimensions asx
. Each element ofy
is the evaluated membership value for the corresponding element ofx
.Vector of
fismf
objects, theny
is an M-by-N matrix, where M and N are the lengths ofmfT1
andx
, respectively.y
(i,j) is the evaluated value of membership functionmfT1
(i) for input valuex
(j).
yUpper
— Upper MF membership values for a type-2 membership function
scalar | 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, theny
is a scalar, vector, or matrix with the same dimensions asx
. Each element ofy
is the evaluated membership value for the corresponding element ofx
.Vector of
fismftype2
objects, theny
is an M-by-N matrix, where M and N are the lengths ofmfT2
andx
, respectively.y
(i,j) is the evaluated value of membership functionmfT2
(i) for input valuex
(j).
yLower
— Lower MF membership values for a type-2 membership function
scalar | 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, theny
is a scalar, vector, or matrix with the same dimensions asx
. Each element ofy
is the evaluated membership value for the corresponding element ofx
.Vector of
fismftype2
objects, theny
is an M-by-N matrix, where M and N are the lengths ofmfT2
andx
, respectively.y
(i,j) is the evaluated value of membership functionmfT2
(i) for input valuex
(j).
Version History
Introduced before R2006aR2018b: fismf
object input argument
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]';
MATLAB Command
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.
Select a Web Site
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: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)