%% Add Membership Function to Fuzzy Variable
% 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

% 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];

% Copyright 2018 The MathWorks, Inc.