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 functionfismf
object | vector of fismf
objectsType-1 membership function, specified as a fismf
object or a vector of such objects.
x
— Input valueInput 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 matrix
Vector of fismf
objects, then you can specify
x
as a scalar or vector
mfT2
— Type-2 membership functionfismftype2
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 functionMembership 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 functionUpper 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 functionLower 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).
evalmf
now takes a fismf
object as an input argumentBehavior 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]';
You have a modified version of this example. Do you want to open this example with your edits?