evalfis with input data file in excel/txt format

2 visualizzazioni (ultimi 30 giorni)
Hello, I want to evaluate my built Mamdani FIS with whole dataset in excel file. I have 73 rows (without header) and 5 columns (with 1 output). Anyone help me with code. Thank you.

Risposte (1)

Prateekshya
Prateekshya il 8 Ott 2024
Hello Muhammad,
To evaluate your Mamdani Fuzzy Inference System (FIS) with a dataset stored in an Excel file, you can use MATLAB's Fuzzy Logic Toolbox along with its ability to read Excel files.
fis = readfis('your_fis_file.fis'); % Replace with your actual FIS file name
  • Use the xlsread function to read your dataset from the Excel file. You need to specify the file name and the range of data if necessary. For more information on xlsread and other related functions, please follow this link: https://www.mathworks.com/help/matlab/ref/xlsread.html
[data, ~, ~] = xlsread('your_data_file.xlsx'); % Replace with your actual Excel file name
  • Assuming your dataset has 4 input columns and 1 output column, you can evaluate the FIS for each row of data using a loop or vectorized operation. The evalfis function is used for this purpose. For more information on the same please go through: https://www.mathworks.com/help/fuzzy/mamfis.evalfis.html
% Preallocate output array
numRows = size(data, 1);
output = zeros(numRows, 1);
% Evaluate FIS for each row
for i = 1:numRows
inputs = data(i, 1:4); % Adjust the indices based on your input columns
output(i) = evalfis(fis, inputs);
end
  • You can display the results or save them back to an Excel file.
disp('FIS Output:');
disp(output);
xlswrite('fis_output.xlsx', output); % Saves the output to a new Excel file
Ensure that the Fuzzy Logic Toolbox is installed before executing these steps. For more information on the same you can follow this link: https://www.mathworks.com/help/fuzzy/
I hope this helps!
  1 Commento
Walter Roberson
Walter Roberson il 8 Ott 2024
Back in 2014 when this question was asked, xlsread() and xlswrite() were appropriate functions to use.
These days, we recommend instead using readmatrix and writematrix
data = readmatrix('your_data_file.xlsx'); % Replace with your actual Excel file name

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by