Can Fuzzy Logic Toolbox output words?
3 ビュー (過去 30 日間)
古いコメントを表示
I have a simple .fis that outputs values between -3 and 3. There are three distinct categories within -3 and 3, meaning between -3 and -1 represents one category, -1 to 1 another, and 1 to 3 the last one. The fuzzy operator outputs numbers, which is what I expected it to do, but when looking at the numbers I'm having to convert in my head which category it is. Not that big of a deal, I know, but is still a minor inconvenience.
So my question is, can I have the fuzzy operator output words instead of numbers? If not, how do I make the matrix that the fuzzy operator is outputting into a specific matrix that says the name of my categories?
2 件のコメント
Olivia Milton-thompson
2018 年 6 月 4 日
Hi Nick, I understand you published this a while ago but I've got the same question as you, and I was wondering if you got a solution in the end?
Thanks :)
回答 (1 件)
Shubham
2024 年 8 月 29 日
Hi Nick,
In MATLAB, if you're working with a Fuzzy Inference System (FIS) and want to map numerical outputs to categorical labels, you can achieve this by post-processing the output. While the FIS itself will output numerical values, you can write a simple script to convert these numbers into corresponding category names.
Here’s how you can do that:
- Create a function or script that maps the output values to category names.
- Use this mapping function to convert the numerical output to the desired labels.
Here’s a sample MATLAB script to illustrate this:
% Define the categories and their corresponding ranges
categories = {'Low', 'Medium', 'High'};
category_ranges = [-3, -1; -1, 1; 1, 3];
% Example output from the FIS
fis_output = [-2.5, 0.5, 2.2, -1.5, 1.5];
% Function to map numerical output to category names
function category_name = mapToCategory(value, categories, category_ranges)
for i = 1:length(categories)
if value >= category_ranges(i, 1) && value <= category_ranges(i, 2)
category_name = categories{i};
return;
end
end
category_name = 'Unknown'; % If the value doesn't fit any category
end
% Convert the FIS outputs to category names
category_labels = arrayfun(@(x) mapToCategory(x, categories, category_ranges), fis_output, 'UniformOutput', false);
% Display the results
disp('FIS Outputs and their corresponding categories:');
for i = 1:length(fis_output)
fprintf('Output: %.2f -> Category: %s\n', fis_output(i), category_labels{i});
end
Explanation:
- You define the categories and their corresponding numerical ranges in the categories and category_ranges arrays.
- The mapToCategory function checks which range the output value falls into and returns the corresponding category name.
- The arrayfun function applies the mapToCategory function to each element of the fis_output array, converting all numerical outputs to category names.
This approach allows you to maintain a clear separation between numerical processing and categorical interpretation, making it easier to manage and update categories as needed.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Fuzzy Logic in Simulink についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!