Evaluate fuzzy membership function
y = evalmf(mf,x)
Evaluate a generalized bell-shaped membership function across a range of input values from
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")
mf— Membership function
fismfobject | vector of
Membership function, specified as a
fismf object or a
x— Input value
Input value, specified as a scalar, vector, or 2-D matrix. If
mf is a:
fismf object, then you can specify
x as a scalar, vector, or matrix.
fismf objects, then you can specify
x as a scalar or vector
y— Output membership value
Output membership value, returned as a scalar, vector, or 2-D matrix. If
mf is a:
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
fismf objects, then
y is an
M-by-N matrix, where
M and N are the lengths of
is the evaluated value of membership function
mf(i) for input value
Behavior changed in R2018b
evalmf now takes a
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
fismf objects to
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,
y = evalmf(x,params,type);
Update your code to first create a
mf. Then, pass this object to
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
mf1 = fismf(type1,params1); mf2 = fismf(type2,params2); mf2 = fismf(type3,params3); y = evalmf([mf1 mf2 mf3],x);
y = [y1 y2 y3]';