How to evaluate a fistree designed with the new addition to the app?
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello,
How can I import and evaluate a fistree designed in the new addition of the FuzzyLogic Toolbox app?
It is saved as .mat file instead of .fis.
Readfis and load do not seem to work to import it to my script. I want to give inputs via evalfis, but it does not seem to work with the .mat file. It seems that it is not recognized as fistree.
Many thanks in advance
댓글 수: 0
답변 (2개)
Abhinaya Kennedy
2023년 11월 9일
Hi Felix,
To import and evaluate a fuzzy inference system (FIS) designed using the Fuzzy Logic Toolbox app and saved as a .mat file, you can follow these steps:
1.Load the .mat file using the load function in MATLAB:
load('fis_file.mat');
2.Once loaded, the FIS will be stored as a structure in the MATLAB workspace. You can access the FIS using its variable name. For example, if the variable name is fis, you can access it as fis.
3.To evaluate the FIS with input values, you can use the evalfis function. However, since the FIS was saved as a .mat file, you need to convert it to a Fuzzy Logic Toolbox object before using evalfis. You can do this using the fis function:
fuzzy_system = fis(fis);
4.Now, you can use the evalfis function to evaluate the fuzzy system with input values. Make sure to pass the input values as a vector or matrix, depending on the number of inputs the FIS has. For example, if the FIS has two inputs, input1 and input2, you can evaluate it as follows:
inputs = [input1, input2];
output = evalfis(fuzzy_system, inputs);
Make sure to replace fis_file.mat with the actual file name of your .mat file. Also, replace input1, input2, and output with the appropriate variable names in your script.
By following these steps, you should be able to import and evaluate the FIS designed in the Fuzzy Logic Toolbox app using a .mat file.
Hope this helps.
댓글 수: 0
Noah West
2024년 8월 19일
Abhinaya Kennedy's solution will not work in this case as fis() is no longer a valid function as of R2024a.
When importing the fistree.mat system, as output by the Fuzzy Logic Designer, it will import as a struct if set equal to a variable when using the load() command. As such to actually grab the fistreemodel object simply reference the child object of the struct as such:
importedTree = load("your_tree_model.mat").fistreemodel;
importedTree will then be the correct fistree object with all inputs, connections, and outputs named/configured. You can check this with:
plotfis(importedTree);
Finally to actually use your system:
inputs = [input1 input2 input3]
outputs = evalfis(importedTree, inputs);
As a fistree contains multiple fis', outputs will contain the output of every individual fis. It is likely you just want the final result of the tree which will be the last element of outputs.
Hope this helps anyone that stumbles upon it,
Cheers.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Fuzzy Inference System Modeling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!