Clear Filters
Clear Filters

how to make graph with nine inputs and one output

15 views (last 30 days)
Mamta
Mamta on 1 Sep 2024
Commented: Sam Chak on 10 Sep 2024 at 7:13
I have make a fis of nine input and one output now i execute surfview('file.fis') in this graph display at a time by taking two input and one output . but my problem is i have nine input and one output . i want to display at a time in a single graph containing all nine inputs and one output for better comparison and readbility. please help its realted to my research work thanks
  4 Comments
Umar
Umar on 10 Sep 2024 at 1:59
Hi @Mamta,
I don’t have fuzzy logic toolbox installed and utilizing mobile matlab to help you out. So, based on your comments, I have edited the code above.
Sam Chak
Sam Chak on 10 Sep 2024 at 7:13
As an observer, I suggest you share / upload the 'file.fis' so that @Umar can look into the matter clearly.

Sign in to comment.

Answers (1)

Umar
Umar on 1 Sep 2024

Hi @Mamta,

Let me address your query regarding, “I have make a fis of nine input and one output now i execute surfview('file.fis') in this graph display at a time by taking two input and one output . but my problem is i have nine input and one output . i want to display at a time in a single graph containing all nine inputs and one output for better comparison and readbility. please help its realted to my research work thanks”

The surfview function in MATLAB is indeed limited to displaying only two inputs at a time along with the output. However, there is an alternative approach you can take to visualize your FIS more effectively by using parallel coordinates. This method will allow you to plot all inputs on parallel axes, making it easier to compare their effects on the output. Here is the updated code,

% Create a new fuzzy inference system using mamfis
fis = mamfis('Name', 'example_fis');

For more information on mamfis function, please refer to

https://www.mathworks.com/help/fuzzy/mamfis.html

% Define nine input variables
for i = 1:9
  fis = addInput(fis, [0 10], 'Name', ['Input ' num2str(i)]);
  fis = addMF(fis, ['Input ' num2str(i)], 'trimf', [0 0 5], 'Name', 'Low');
  fis = addMF(fis, ['Input ' num2str(i)], 'trimf', [5 10 10], 'Name', 'High');
end
% Define one output variable
fis = addOutput(fis, [0 100], 'Name', 'Output');
fis = addMF(fis, 'Output', 'trimf', [0 0 50], 'Name', 'Low');
fis = addMF(fis, 'Output', 'trimf', [50 100 100], 'Name', 'High');
% Sample data generation
num_samples = 100;
input_data = rand(num_samples, 9) * 10; % Random input data
output_data = rand(num_samples, 1) * 100; % Random output data
% Create a figure for parallel coordinates
figure;
hold on;
% Normalize the input data
input_data_norm = (input_data - min(input_data)) ./ (max(input_data) -     
min(input_data));
% Plot parallel coordinates
for i = 1:num_samples
  plot(input_data_norm(i,:), output_data(i), '-o', 'MarkerFaceColor', 'b');
end
xlabel('Normalized Inputs');
ylabel('Output');
title('Output Visualization Based on All Inputs');
grid on;
hold off;

So, as you can see the code initializes a new Mamdani fuzzy inference system (fis) and adds nine input variables, each with a triangular membership function (MF) for Low and High classifications and defines one output variable with similar membership functions which makes sure that you can effectively evaluate how changes in each input influence the output. Then, it generates random sample data for both inputs and outputs, where you might have varying input conditions leading to different outputs. Afterwards, the visualization is achieved through parallel coordinates plotting, which is particularly useful for comparing multiple dimensions (in this case, inputs) against a single dimension (the output). The line input_data_norm = (input_data - min(input_data)) ./ (max(input_data) - min(input_data)); normalizes the input data by making sure that all input variables are on the same scale, facilitating better visualization. A loop iterates through each sample, plotting normalized inputs against the corresponding output value which allows you to see how each combination of input values corresponds to the output.

Please see attached.

If you have any further questions, please let me know.

  3 Comments
Umar
Umar on 1 Sep 2024

Hi @Mamta,

I modified the existing code for a FIS based on your request which now includes three membership functions for each input and four membership functions for the output. Here’s an updated version of the code that incorporates these specifications.

% Create a new fuzzy inference system using mamfis
fis = mamfis('Name', 'example_fis');
% Define three input variables
for i = 1:3
  fis = addInput(fis, [0 10], 'Name', ['Input ' num2str(i)]);
  fis = addMF(fis, ['Input ' num2str(i)], 'trimf', [0 0 5], 
  'Name', 'Low');
  fis = addMF(fis, ['Input ' num2str(i)], 'trimf', [2.5 5 7.5], 
  'Name', 'Medium');
  fis = addMF(fis, ['Input ' num2str(i)], 'trimf', [5 10 10], 
 'Name', 'High');
end
% Define one output variable with four membership functions
fis = addOutput(fis, [0 100], 'Name', 'Output');
fis = addMF(fis, 'Output', 'trimf', [0 0 25], 'Name', 'Very 
Low');
fis = addMF(fis, 'Output', 'trimf', [10 30 50], 'Name', 'Low');
fis = addMF(fis, 'Output', 'trimf', [40 70 90], 'Name', 'High');
fis = addMF(fis, 'Output', 'trimf', [75 100 100], 'Name', 'Very
High');
% Sample data generation
num_samples = 100;
input_data = rand(num_samples, 3) * 10; % Random input data
output_data = rand(num_samples, 1) * 100; % Random output data
% Create a figure for parallel coordinates
figure;
hold on;
% Normalize the input data
input_data_norm = (input_data - min(input_data)) ./ 
(max(input_data) - min(input_data));
% Plot parallel coordinates
for i = 1:num_samples
  plot(input_data_norm(i,:), output_data(i), '-o', 
  'MarkerFaceColor', 'b');
end
xlabel('Normalized Inputs');
ylabel('Output');
title('Output Visualization Based on All Inputs');
grid on;
hold off;

So, you can see in the code that each of the three input variables has been assigned three triangular membership functions: Low, Medium, and High. The parameters for these functions were chosen to provide a clear division between the categories. The output variable now has four membership functions: Very Low, Low, High and Very High. These functions help categorize the output more finely, allowing for better differentiation in the results. The random sample data generation accommodates three inputs instead of nine, in line with the revised setup and the parallel coordinates plot remains unchanged, as it effectively visualizes the relationship between the normalized inputs and the output.

If you have further questions or need additional modifications, feel free to ask!

Sam Chak
Sam Chak on 1 Sep 2024
@Mamta, if you have designed the fuzzy system, please provide it to @Umar. However, in the sample code, the 'fis' object remains unused after its creation. The 'fis' is neither utilized in the plot nor in the data analysis. A bit strange?

Sign in to comment.

Categories

Find more on Deployment in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!