Problem with use of fuzarith

4 Ansichten (letzte 30 Tage)
ABHIJEET KUMAR
ABHIJEET KUMAR am 24 Mär. 2021
Beantwortet: Zuber Khan am 25 Sep. 2024
S = 6; M = 10; %No. of sub-tasks and no. of service providers
beta = [0.12 0.27 0.19 0.16 0.18 0.08]; %Respecrtive weights of each sub-task
e = randi([0 1],1,M); %Randomly produce 0 and 1. 1 implies provider is selected
cmin = 36 + (70 - 36)*rand(1,M); %Randomly generate 'a' for triangular fuzzy no.
cmed = 58 + (93 - 58)*rand(1,M); %Randomly henerate 'b'
cmax = 81 + (120 - 81)*rand(1,M); %Randomly generate 'c'
x= 0:5:200;
csum = trimf(x,[0 0 0]);
csum1 = trimf(x,[0 0 0]);
ctot = trimf(x,[0 0 0]);
X = (cmin<=cmed)&(cmed<=cmax); %Logical matrix to check that (a<=b) and (b<=c)
for i= 1:S %for loop runs S times (=6)
for j= 1:M %for loop runs M times (=10)
if X(1,j)==1 %Necessary condition for delection of a,b and c
cost = trimf(x,[cmin(1,j) cmed(1,j) cmax(1,j)]); %Initialize cost triangular fuzzy no.
cost = e(1,j).*cost; %Random selection of service provider
csum = fuzarith(x,csum,cost,'sum'); %Summation
csum = csum';
end
end
csum1 = csum;
csum1 = beta(1,i).*csum1; %Multiply sum by respective weights of subtasks
ctot = fuzarith(x,ctot,csum1,'sum'); %Final summation
csum = trimf(x,[0 0 0]); %Reset sum = 0
end
I keep getting this error
Error using >
Matrix dimensions must agree.
Error in fuzarith (line 65)
index3 = find(height > max(B(index1B)));
Error in form1 (line 20) [form1 is the name of file I am working on]

Antworten (1)

Zuber Khan
Zuber Khan am 25 Sep. 2024
Hi,
I tried to reproduce this issue. Although I did not receive the same error message as you have mentioned, but I got the following run time error:
% Error using fuzarith>validateInputValues (line 145)
% Fuzzy sets must be finite real vectors with the same length as the univese of discourse and with at least one
% positive membership value.
%
% Error in fuzarith (line 49)
% validateInputValues(x,A,B,operator)
% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
% Error in untitled (line 18)
% csum = fuzarith(x,csum,cost,'sum'); %Summation
% ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Upon debugging further, I found that though the dimensions of variables 'x', 'csum' and 'cost' are same, but for one of the iteration, all the values of 'cost' are zero.
As per my understanding, each element of 'cost' refers to cost triangular fuzzy set value for the corresponding value of 'x' and is getting randomly selected due to the following multiplication operation:
cost = e(1,j).*cost;
Now, 'e' has been defined as follows:
e = randi([0 1],1,M);
Since, 'e' is a randomly generated vector containing either 0 or 1, the value of 'cost' will become zero whenever 'e' is zero. This is the reason behind the run-time error.
Please note that by definition of "fuzarith" function as mentioned below,
C = fuzarith(X,A,B,operator);
the input arguements 'A' and 'B' must be convex fuzzy set. A fuzzy set with all zero membership values is essentially empty, providing no useful information. Therefore, you would need to check the logic of randomly selecting the membership values and change the code accordingly.
I hope it will help to resolve the issue.
Regards,
Zuber

Kategorien

Mehr zu Fuzzy Inference System Modeling finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by