Main Content

fisvar

Fuzzy variable

Description

Use fisvar objects to represent the input and output variables in a fuzzy inference system (FIS). For more information on creating fuzzy inference systems, see mamfis, sugfis, mamfistype2, and sugfistype2.

Creation

Description

example

var = fisvar creates a fuzzy variable with a default name, default range, and no membership functions. To change the variable properties, use dot notation.

example

var = fisvar(range) sets the Range property.

example

var = fisvar('Name',name) sets the Name property.

var = fisvar(range,'Name',name) sets both the Range and Name properties.

Properties

expand all

Variable name, specified as a string or character vector.

Variable range, specified as a two-element element vector where the first element is less than the second element. The first element specifies the lower bound of the range, and the second element specifies the upper bound of the range.

Membership functions, specified as a vector of fismf or fismftype2 objects. To add membership functions to a fuzzy variable:

  • Use the addMF function.

  • Create a vector of fismf objects, and assign it to MembershipFunctions.

  • Create a vector of fismftype2 objects, and assign it to MembershipFunctions.

You can modify the properties of the membership functions using dot notation.

Object Functions

addMFAdd membership function to fuzzy variable
removeMFRemove membership function from fuzzy variable

Examples

collapse all

Create a fuzzy variable with default properties.

var = fisvar;

To modify the properties of a fisvar object, use dot notation. For example, specify the range of the fuzzy variable to be from -5 to 5.

var.Range = [-5 5];

Create a fuzzy variable with an input range from -10 to 10.

var = fisvar([-10 10]);

Create a fuzzy variable with the name "speed".

var = fisvar("Name","speed");

Create a fuzzy variable with a specified range.

var = fisvar([0 1]);

Add a membership function to the variable, specifying a trapezoidal membership function, and set the membership function parameters.

var = addMF(var,"trapmf",[-0.5 0 0.2 0.4]);

You can also specify the name of your membership when you add it to a fuzzy variable. For example, add a membership function called "large".

var = addMF(var,"trapmf",[0.6 0.8 1 1.5],'Name',"large");

View the membership functions.

var.MembershipFunctions
ans = 
  1x2 fismf array with properties:

    Type
    Parameters
    Name

  Details:
          Name        Type               Parameters         
         _______    ________    ____________________________

    1    "mf1"      "trapmf"    -0.5       0     0.2     0.4
    2    "large"    "trapmf"     0.6     0.8       1     1.5

Alternatively, you can add a default membership function to a fuzzy variable and set its parameters using dot notation.

var = fisvar([0 1]);
var = addMF(var);
var.MembershipFunctions(1).Type = "trapmf";
var.MembershipFunctions(1).Parameters = [-0.5 0 0.2 0.4];

Create a fuzzy variable with a specified range. By default, this variable has no membership functions.

var = fisvar([0 9]);

To add a type-2 membership function to a variable with no existing membership functions, specify either a LowerLag or LowerScale value for the membership function. For example specify a lower scale value.

var = addMF(var,"trimf",[0 3 6],'LowerScale',1);

Once a variable contains a type-2 membership function, you can add additional type-2 membership functions without specifying one of these parameters.

var = addMF(var,"trimf",[3 6 9]);

View the membership functions.

var.MembershipFunctions
ans = 
  1x2 fismftype2 array with properties:

    Type
    UpperParameters
    LowerScale
    LowerLag
    Name

  Details:
         Name      Type      Upper Parameters    Lower Scale    Lower Lag 
         _____    _______    ________________    ___________    __________

    1    "mf1"    "trimf"      0    3    6            1         0.2    0.2
    2    "mf2"    "trimf"      3    6    9            1         0.2    0.2

Introduced in R2018b