%% Train ANFIS with Custom Number of Training Epochs
% Create single-input, single-output training data.

x = (0:0.1:10)';
y = sin(2*x)./exp(x/5);

%
% Define an FIS structure with five input membership functions.

genOpt = genfisOptions('GridPartition','NumMembershipFunctions',5);
inFIS = genfis(x,y,genOpt);

%
% Configure the training options. Specify 20 training epochs and suppress the Command Window display.

opt = anfisOptions('InitialFIS',inFIS,'EpochNumber',20);
opt.DisplayANFISInformation = 0;
opt.DisplayErrorValues = 0;
opt.DisplayStepSize = 0;
opt.DisplayFinalResults = 0;

%
% Train the FIS using the specified options.

outFIS = anfis([x y],opt);

%
% Compare the ANFIS output with the training data.

plot(x,y,x,evalfis(outFIS,x))
legend('Training Data','ANFIS Output')