%% Transform Mamdani FIS into Sugeno FIS
% Load a Mamdani fuzzy inference system.

mam_fismat = readfis('mam22.fis');

%
% Convert this system to a Sugeno fuzzy inference system.

sug_fismat = convertToSugeno(mam_fismat);

%
% Plot the output surfaces for both fuzzy systems.

subplot(2,2,1)
gensurf(mam_fismat)
title('Mamdani system (Output 1)')
subplot(2,2,2)
gensurf(sug_fismat)
title('Sugeno system (Output 1)')
subplot(2,2,3)
gensurf(mam_fismat,gensurfOptions('OutputIndex',2))
title('Mamdani system (Output 2)')
subplot(2,2,4)
gensurf(sug_fismat,gensurfOptions('OutputIndex',2))
title('Sugeno system (Output 2)')

% The output surfaces for both systems are similar.