How to create .fis file with 2042 numerical values as input for a fuzzy system

4 views (last 30 days)
hi friends, please help me in creating .fis file for giving input in fuzzy for 2042 numerical values

Answers (1)

Sam Chak
Sam Chak on 1 May 2025
A FIS file (*.fis) can only be created when saving the fuzzy inference system (FIS) object to the current working folder using the syntax writeFIS(fis, fileName). The 2042 numerical values represent a set of data points that you want to use as input for a fuzzy system. Thus, I believe you are likely trying to design a fuzzy inference system but may not know how to define the fuzzy logic rules and membership functions (MFs) based on this data.
If you are an expert in the field, you may have already shaped the MFs based on semantic understanding, such as {"small", "medium", "big"} or {"negative", "zero", "positive"}, and defined the rules based on your expert knowledge. Since you posted here, it seems you are considering a different approach, preferring to let the fuzzy logic toolbox solve the problem automatically. This can be accomplished by using the anfis() function.
Please take a look at the demo below, where the data comes from this curve-fitting problem:
load("data.mat");
x = f; % input
y = pxx; % output
xq = linspace(f(1), f(end), 2042)';
yq = interp1(x, y, xq, 'spline');
figure
plot(xq, yq, '.'), grid on
xlabel('x'), ylabel('y')
title('2042 data points')
%% ANFIS
% set up initial FIS
genOpt = genfisOptions('GridPartition');
genOpt.NumMembershipFunctions = 40;
genOpt.InputMembershipFunctionType = 'gaussmf';
genOpt.OutputMembershipFunctionType = 'constant';
iniFIS = genfis(xq, yq, genOpt);
% specify ANFIS options for tuning fuzzy systems
opt = anfisOptions('InitialFIS', iniFIS, 'EpochNumber', 1000);
opt.DisplayANFISInformation = 0;
opt.DisplayErrorValues = 0;
opt.DisplayStepSize = 0;
opt.DisplayFinalResults = 0;
% tune Sugeno FIS using training data
outFIS = anfis([xq yq], opt);
%% Plot results
figure
tl = tiledlayout(2, 2, 'TileSpacing', 'Compact');
nexttile
plotmf(outFIS, 'input', 1, 2042),
grid on, ylim([-0.5, 1.5])
xlim([0 250])
xlabel(''), ylabel('')
title('mf1 – mf10')
delete(findobj(gca, 'Type', 'text'));
nexttile
plotmf(outFIS, 'input', 1, 2042),
grid on, ylim([-0.5, 1.5])
xlim([250 500])
xlabel(''), ylabel('')
title('mf11 – mf20')
delete(findobj(gca, 'Type', 'text'));
nexttile
plotmf(outFIS, 'input', 1, 2042),
grid on, ylim([-0.5, 1.5])
xlim([500 750])
xlabel(''), ylabel('')
title('mf21 – mf30')
delete(findobj(gca, 'Type', 'text'));
nexttile
plotmf(outFIS, 'input', 1, 2042),
grid on, ylim([-0.5, 1.5])
xlim([750 1000])
xlabel(''), ylabel('')
title('mf31 – mf40')
delete(findobj(gca, 'Type', 'text'));
xlabel(tl, 'Input, x')
ylabel(tl, 'Degree of membership')
title(tl, '40 Input Gaussian MFs')
figure
plot(x, y, 'o'), hold on
plot(xq, evalfis(outFIS, xq), 'linewidth', 1.5), hold off
grid on, % ylim([-1 13])
legend('Original Data', 'ANFIS Output', 'location', 'best')
xlabel('x'), ylabel('y')
title('Fitting ANFIS model into the data')

Categories

Find more on Fuzzy Logic Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!