The problem is, that I have to find parameter, which has the biggest influence to outputs. I have two outputs, they are interdependent.
How to prepare data from excel for fuzzy analysis.
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have an problem with preparing data for fuzzy analysis. I have 16 groups of data which are inputs and 2 groups of data which are outputs. It is data which was measured and I have abou 3500 lines. I have these data in MS excel and I have to prepare it for FUZZY. Do you know how to do it, please? I have no experience with matlab and fuzzy analysis, but I need it for my master thesis, it will be really nice if somebody help me.
Risposte (1)
Prateekshya
il 16 Ott 2024
Hello Petra,
Preparing data for fuzzy analysis involves organizing your data in a way that can be used to create a fuzzy inference system (FIS). Since you are using MATLAB, you'll likely be working with the Fuzzy Logic Toolbox, which provides tools to create and evaluate fuzzy systems. Here's a step-by-step guide to help you prepare your data and set up a fuzzy system:
Step 1: Import Data from Excel
First, you will need to import your data from Excel into MATLAB. You can do this using the `readtable` function, which reads data into a table format.
% Import data from Excel
data = readtable('your_data_file.xlsx');
Step 2: Organize Your Data
Assuming your Excel file has headers, you can access your input and output data:
% Extract input and output data
inputs = data{:, 1:16}; % Assuming the first 16 columns are inputs
outputs = data{:, 17:18}; % Assuming the next 2 columns are outputs
Step 3: Create a Fuzzy Inference System
You can create a fuzzy inference system using the Fuzzy Logic Designer in MATLAB or programmatically. Here, I'll show you how to do it programmatically.
% Create a new FIS
fis = newfis('MyFuzzySystem');
% Add input variables
for i = 1:16
fis = addvar(fis, 'input', ['Input' num2str(i)], [min(inputs(:,i)) max(inputs(:,i))]);
% Add membership functions for each input
fis = addmf(fis, 'input', i, 'Low', 'trimf', [min(inputs(:,i)) min(inputs(:,i)) mean(inputs(:,i))]);
fis = addmf(fis, 'input', i, 'Medium', 'trimf', [min(inputs(:,i)) mean(inputs(:,i)) max(inputs(:,i))]);
fis = addmf(fis, 'input', i, 'High', 'trimf', [mean(inputs(:,i)) max(inputs(:,i)) max(inputs(:,i))]);
end
% Add output variables
for j = 1:2
fis = addvar(fis, 'output', ['Output' num2str(j)], [min(outputs(:,j)) max(outputs(:,j))]);
% Add membership functions for each output
fis = addmf(fis, 'output', j, 'Low', 'trimf', [min(outputs(:,j)) min(outputs(:,j)) mean(outputs(:,j))]);
fis = addmf(fis, 'output', j, 'Medium', 'trimf', [min(outputs(:,j)) mean(outputs(:,j)) max(outputs(:,j))]);
fis = addmf(fis, 'output', j, 'High', 'trimf', [mean(outputs(:,j)) max(outputs(:,j)) max(outputs(:,j))]);
end
Step 4: Define Fuzzy Rules
Fuzzy rules define how the inputs are related to the outputs. You can add rules like this:
% Add rules
rules = [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1; % Example rule
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 1 1]; % Another example rule
fis = addrule(fis, rules);
Step 5: Evaluate the FIS
Once your FIS is set up, you can evaluate it with your data.
% Evaluate the fuzzy system
outputResults = evalfis(inputs, fis);
Step 6: Analyze and Visualize
You can visualize the results and analyze the performance of your fuzzy system using various MATLAB plotting functions.
% Plot results
figure;
plot(outputs, 'o'); % Actual outputs
hold on;
plot(outputResults, 'x'); % FIS outputs
legend('Actual', 'FIS Predicted');
title('Fuzzy System Output vs. Actual Output');
I hope this helps!
0 Commenti
Vedere anche
Categorie
Scopri di più su Fuzzy Logic in Simulink in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!