evalfis with input data file in excel/txt format

2 次查看(过去 30 天)
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.

回答(1 个)

Prateekshya
Prateekshya 2024-10-8
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 个评论
Walter Roberson
Walter Roberson 2024-10-8
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by