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